Commit 9cf5e4d8 authored by frank.xa.zhang's avatar frank.xa.zhang

fixed report display issue

parent ef7e84a6
......@@ -2,4 +2,5 @@ package pwc.taxtech.atms.constant;
public final class Constant {
public static final String Comma = ",";
public static final String Other = "其他";
}
package pwc.taxtech.atms.constant.enums;
public enum RoleSource {
Unknown(0),
OrganizationLevel(1),
AreaLevel(2),
BusinessUnitLevel(3),
OriginalLevel(4),
DimensionLevel(5),
/**
* //维度的原始角色
*/
DimensionOriginalLevel(6),
/**
* //维度的附加角色
*/
DimensionExraLevel(7),
/**
* //机构的原始角色
*/
OrganizationOriginaLevel(8),
/**
* 机构的附加角色
*/
OrganizationExtraLevel(9);
private Integer code;
RoleSource(Integer code) {
this.code = code;
}
public Integer getCode() {
return code;
}
}
......@@ -46,7 +46,7 @@ public class RuleEngineeConfigController {
@RequestMapping(value="taxRuleSetting/Save",method = RequestMethod.POST)
public void SaveTaxRuleSettings(@RequestBody BatchUpdateTaxRuleDto batchUpdateTaxRule) {
logger.debug("RuleEngineeConfigController SaveTaxRuleSettings");
ruleEngineeConfigService.SaveTaxRuleSettings(batchUpdateTaxRule);
ruleEngineeConfigService.savetaxrulesettings(batchUpdateTaxRule);
}
}
\ No newline at end of file
......@@ -6,10 +6,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.*;
import pwc.taxtech.atms.common.ApplicationException;
import pwc.taxtech.atms.dto.TemplateDto;
import pwc.taxtech.atms.dto.TemplateUniqDto;
import pwc.taxtech.atms.service.TemplateService;
import javax.servlet.http.HttpServletResponse;
......@@ -64,7 +64,7 @@ public class TemplateController {
}
filePath = this.getClass().getResource("").toURI().getPath();
String tempPath = filePath.substring(0,filePath.indexOf("classes")+"\\classes".length());
String tempPath = filePath.substring(0, filePath.indexOf("classes") + "\\classes".length());
templateFile = new File(tempPath + templateService.getTemplatePath(templateID));
try {
......@@ -73,11 +73,11 @@ public class TemplateController {
String customFileName = "template_" + DateTime.now().toString("yyyyMMddHHmmss") + ".xlsx";
response.setHeader("Content-Disposition", String.format("inline; filename=\"" + customFileName + "\""));
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
int len=0;
int len = 0;
byte[] buffer = new byte[1024];
OutputStream out = response.getOutputStream();
while ((len=inputStream.read(buffer))>0){
out.write(buffer,0,len);
while ((len = inputStream.read(buffer)) > 0) {
out.write(buffer, 0, len);
}
//FileCopyUtils.copy(inputStream, response.getOutputStream());
......@@ -98,6 +98,11 @@ public class TemplateController {
inputStream = null;
}
}
}
@RequestMapping(value = "getTemplateUniqList", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
List<TemplateUniqDto> getTemplateUniqList(String serviceTypeID, Integer payTaxType, Integer reportType, String industryIDs) {
return templateService.getTemplateUniqList(serviceTypeID, payTaxType, reportType, industryIDs);
}
}
package pwc.taxtech.atms.dao;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyMapper;
import pwc.taxtech.atms.dto.TemplateUniqDto;
import pwc.taxtech.atms.entitiy.Template;
import pwc.taxtech.atms.entitiy.TemplateExample;
......@@ -105,4 +108,14 @@ public interface TemplateMapper extends MyMapper {
* @mbg.generated
*/
int updateByPrimaryKey(Template record);
/**
* 获取TemplateUniqDto
* @param serviceTypeID
* @param payTaxType
* @param reportType
* @param indeustryIDs
* @return TemplateUniqDto List
*/
List<TemplateUniqDto> getTemplateUniqDtosByTemplateAndTemplateGroup(Map<String,Object> map);
}
\ No newline at end of file
package pwc.taxtech.atms.dto;
import pwc.taxtech.atms.constant.enums.RoleSource;
public class NameDto {
private String ID;
private String name;
private RoleSource RoleSource;
public String getID() {
return ID;
}
public void setID(String ID) {
this.ID = ID;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package pwc.taxtech.atms.dto;
public class TemplateUniqDto {
private String ID;
private String code;
private String name;
private Integer orderIndex;
private Integer reportType;
private String templateGroupID;
private String templateGroupName;
private String parentID;
private String parentName;
/**
* template type
*/
private Integer payTaxType;
private String industryIDs;
private String serviceTypeID;
private boolean isActiveAssociation;
public String getID() {
return ID;
}
public void setID(String ID) {
this.ID = ID;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getOrderIndex() {
return orderIndex;
}
public void setOrderIndex(Integer orderIndex) {
this.orderIndex = orderIndex;
}
public Integer getReportType() {
return reportType;
}
public void setReportType(Integer reportType) {
this.reportType = reportType;
}
public String getTemplateGroupID() {
return templateGroupID;
}
public void setTemplateGroupID(String templateGroupID) {
this.templateGroupID = templateGroupID;
}
public String getTemplateGroupName() {
return templateGroupName;
}
public void setTemplateGroupName(String templateGroupName) {
this.templateGroupName = templateGroupName;
}
public String getParentID() {
return parentID;
}
public void setParentID(String parentID) {
this.parentID = parentID;
}
public String getParentName() {
return parentName;
}
public void setParentName(String parentName) {
this.parentName = parentName;
}
public Integer getPayTaxType() {
return payTaxType;
}
public void setPayTaxType(Integer payTaxType) {
this.payTaxType = payTaxType;
}
public String getIndustryIDs() {
return industryIDs;
}
public void setIndustryIDs(String industryIDs) {
this.industryIDs = industryIDs;
}
public String getServiceTypeID() {
return serviceTypeID;
}
public void setServiceTypeID(String serviceTypeID) {
this.serviceTypeID = serviceTypeID;
}
public boolean getIsActiveAssociation() {
return isActiveAssociation;
}
public void setIsActiveAssociation(boolean isActiveAssociation) {
this.isActiveAssociation = isActiveAssociation;
}
}
......@@ -11,5 +11,5 @@ public interface RuleEngineeConfigService {
List<TaxRuleSettingDto> GetTaxRuleSetting();
void SaveTaxRuleSettings(BatchUpdateTaxRuleDto batchUpdateTaxRule);
void savetaxrulesettings(BatchUpdateTaxRuleDto batchUpdateTaxRule);
}
package pwc.taxtech.atms.service;
import pwc.taxtech.atms.dto.TemplateDto;
import pwc.taxtech.atms.dto.TemplateUniqDto;
import java.util.List;
......@@ -13,4 +14,6 @@ public interface TemplateService {
List<TemplateDto> get(String templateGroupID, Integer reportType);
String getTemplatePath(String templateID);
List<TemplateUniqDto> getTemplateUniqList(String serviceTypeID, Integer payTaxType, Integer reportType, String industryIDs);
}
......@@ -44,7 +44,7 @@ public class RuleEngineeConfigServiceImpl extends AbstractService implements Rul
List<String> orgIDs = organizationMapper.selectOnlyIDAndParentID().stream().map(OrganizationDto::getID)
.collect(Collectors.toList());
List<TaxPayerReportRule> rules = taxPayerReportRuleMapper.selectByExample(new TaxPayerReportRuleExample());
List<TaxPayerReportRule> filterRules = new ArrayList<TaxPayerReportRule>();
List<TaxPayerReportRule> filterRules = new ArrayList<>();
for (TaxPayerReportRule rule : rules) {
String[] selectedOrgIds = rule.getOrganizationID().split(",");
......@@ -61,7 +61,7 @@ public class RuleEngineeConfigServiceImpl extends AbstractService implements Rul
}
}
List<TaxPayerReportRuleDto> dtoList = new ArrayList<TaxPayerReportRuleDto>();
List<TaxPayerReportRuleDto> dtoList = new ArrayList<>();
for (TaxPayerReportRule rule : filterRules) {
TaxPayerReportRuleDto ruleDto = new TaxPayerReportRuleDto();
CommonUtils.copyProperties(rule, ruleDto);
......@@ -82,8 +82,8 @@ public class RuleEngineeConfigServiceImpl extends AbstractService implements Rul
}
@Override
@Transactional
public void SaveTaxRuleSettings(BatchUpdateTaxRuleDto batchUpdateTaxRule) {
@Transactional(readOnly = true)
public void savetaxrulesettings(BatchUpdateTaxRuleDto batchUpdateTaxRule) {
for (TaxRuleSettingOperation trso : batchUpdateTaxRule.getTaxRuleSettingOperations()) {
TaxRuleSetting taxRuleSetting = new TaxRuleSetting();
CommonUtils.copyProperties(trso.getTaxRuleSetting(), taxRuleSetting);
......@@ -126,12 +126,12 @@ public class RuleEngineeConfigServiceImpl extends AbstractService implements Rul
taxPayerReportRule.setCreateTime(new Date());
taxPayerReportRule.setUpdateTime(new Date());
SaveOrganizationServiceTemplateGroup(taxPayerReportRule,tprrdo.getAction());
if(tprrdo.getAction()=="Add") {
if(tprrdo.getAction().equals("Add")) {
taxPayerReportRuleMapper.insert(taxPayerReportRule);
operationService.AddDataAddLog(taxPayerReportRule, OperationModule.RuleEngineConfig, authUserHelper.getCurrentUserID(),
"AddRuleEngineConfiguration", "纳税类型", "纳税类型添加特殊机构", OperateLogType.OperationLogRuleEngine);
}
else if(tprrdo.getAction()=="Update") {
else if(tprrdo.getAction().equals("Update")) {
TaxPayerReportRule old = taxPayerReportRuleMapper.selectByPrimaryKey(reportDto.getID());
TaxPayerReportRule original = new TaxPayerReportRule();
CommonUtils.copyProperties(old, original);
......@@ -147,7 +147,7 @@ public class RuleEngineeConfigServiceImpl extends AbstractService implements Rul
"UpdateRuleEngineConfiguration", "纳税类型", taxPayerReportRule.getIsDefault() ? "默认纳税类型或默认纳税报表" : "纳税类型更新特殊机构", OperateLogType.OperationLogRuleEngine);
}
else if(tprrdo.getAction()=="Delete") {
else if(tprrdo.getAction().equals("Delete")) {
taxPayerReportRuleMapper.deleteByPrimaryKey(taxPayerReportRule.getID());
operationService.DeleteDataAddLog(reportDto, OperationModule.RuleEngineConfig, authUserHelper.getCurrentUserID(),
"DeleteRuleEngineConfiguration", "纳税类型", "纳税类型删除特殊机构", OperateLogType.OperationLogRuleEngine);
......@@ -184,7 +184,7 @@ public class RuleEngineeConfigServiceImpl extends AbstractService implements Rul
example.createCriteria().andOrganizationIDEqualTo(taxPayerReportRule.getOrganizationID()).andServiceTypeIDEqualTo("2");
Optional<OrganizationServiceTemplateGroup> thisOrgTemplate = organizationServiceTemplateGroupMapper.selectByExample(example).stream().findFirst();
if(action=="Delete") {
if(action.equals("Delete")) {
if(thisOrgTemplate.isPresent()) {
organizationServiceTemplateGroupMapper.deleteByPrimaryKey(thisOrgTemplate.get().getID());
}
......@@ -193,7 +193,7 @@ public class RuleEngineeConfigServiceImpl extends AbstractService implements Rul
{
if(thisOrgTemplate.isPresent()) {
OrganizationServiceTemplateGroup organizationServiceTemplateGroup = thisOrgTemplate.get();
if(organizationServiceTemplateGroup.getTemplateGroupID()==taxPayerReportRule.getTemplateGroupID()) {
if(organizationServiceTemplateGroup.getTemplateGroupID().equals(taxPayerReportRule.getTemplateGroupID())) {
//不用改
}
else
......
......@@ -2,13 +2,18 @@ package pwc.taxtech.atms.service.impl;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.dto.NameDto;
import pwc.taxtech.atms.dto.TemplateDto;
import pwc.taxtech.atms.dto.TemplateUniqDto;
import pwc.taxtech.atms.entitiy.Template;
import pwc.taxtech.atms.entitiy.TemplateExample;
import pwc.taxtech.atms.service.TemplateService;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.groupingBy;
@Service
public class TemplateServiceImpl extends AbstractService implements TemplateService {
......@@ -50,4 +55,63 @@ public class TemplateServiceImpl extends AbstractService implements TemplateServ
}
return result;
}
@Override
public List<TemplateUniqDto> getTemplateUniqList(String serviceTypeID, Integer payTaxType, Integer reportType, String industryIDs) {
Map<String, Object> map = new HashMap<>(4);
map.put("serviceTypeID", serviceTypeID);
map.put("payTaxType", payTaxType);
map.put("reportType", reportType);
map.put("industryIDs", industryIDs);
List<TemplateUniqDto> templatedbList = templateMapper.getTemplateUniqDtosByTemplateAndTemplateGroup(map);
Map<String, Map<String, List<TemplateUniqDto>>> groupList = templatedbList.stream().filter(sa -> sa.getIsActiveAssociation()).collect(groupingBy(TemplateUniqDto::getTemplateGroupID, Collectors.groupingBy(TemplateUniqDto::getTemplateGroupName)));
List<NameDto> groupListResult = new ArrayList<>();
groupList.forEach((key, value) -> {
NameDto temp = new NameDto();
temp.setID(key);
value.forEach((key2, value2) -> {
temp.setName(key2);
});
groupListResult.add(temp);
});
List<TemplateUniqDto> result = new ArrayList<>();
for (NameDto group : groupListResult) {
TemplateUniqDto parent = new TemplateUniqDto();
parent.setID(group.getID());
parent.setCode("");
parent.setName(group.getName());
result.add(parent);
List<TemplateUniqDto> subList = templatedbList.stream().filter(sa -> sa.getTemplateGroupID() == group.getID() && sa.getIsActiveAssociation()).collect(Collectors.toList());
subList.forEach(sa -> {
sa.setParentID(sa.getTemplateGroupID());
sa.setParentName(sa.getTemplateGroupName());
});
result.addAll(subList);
}
List<TemplateUniqDto> noGroupTemplateList = templatedbList.stream().filter(sa -> !sa.getIsActiveAssociation()).collect(Collectors.toList());
if (!noGroupTemplateList.isEmpty()) {
TemplateUniqDto parent = new TemplateUniqDto();
parent.setID(UUID.fromString("").toString());
parent.setCode("");
parent.setName(Constant.Other);
result.add(parent);
noGroupTemplateList.forEach(sa -> {
sa.setParentID(parent.getID());
sa.setParentName(parent.getName());
});
result.addAll(noGroupTemplateList);
}
return result;
}
}
......@@ -398,4 +398,37 @@
order by ${orderByClause}
</if>
</select>
<resultMap id="TemplateUniqDto" type="pwc.taxtech.atms.dto.TemplateUniqDto">
<id column="ID" jdbcType="VARCHAR" property="ID" />
<result column="Code" jdbcType="VARCHAR" property="Code" />
<result column="Name" jdbcType="VARCHAR" property="Name" />
<result column="OrderIndex" jdbcType="INTEGER" property="OrderIndex" />
<result column="ReportType" jdbcType="INTEGER" property="ReportType" />
<result column="TemplateGroupID" jdbcType="VARCHAR" property="TemplateGroupID" />
<result column="TemplateGroupName" jdbcType="VARCHAR" property="TemplateGroupName" />
<result column="ParentID" jdbcType="VARCHAR" property="ParentID" />
<result column="ParentName" jdbcType="VARCHAR" property="ParentName" />
<result column="PayTaxType" jdbcType="INTEGER" property="PayTaxType" />
<result column="IndustryIDs" jdbcType="VARCHAR" property="IndustryIDs" />
<result column="ServiceTypeID" jdbcType="VARCHAR" property="ServiceTypeID" />
<result column="IsActiveAssociation" jdbcType="INTEGER" property="IsActiveAssociation" />
</resultMap>
<select id="getTemplateUniqDtosByTemplateAndTemplateGroup" parameterType="map" resultMap="TemplateUniqDto" >
SELECT p.ID,p.Code,p.Name,p.ReportType,q.ID as TemplateGroupID,q.Name as TemplateGroupName,p.IsActiveAssociation FROM Template p join TemplateGroup q on p.templategroupID=q.ID
<if test="serviceTypeID">
WHERE q.ServiceTypeID=#{serviceTypeID,jdbcType=VARCHAR}
</if>
<if test="payTaxType!=null">
AND q.PayTaxType = #{payTaxType,jdbcType=INTEGER}
</if>
<if test="reportType!=null">
AND p.ReportType =#{reportType,jdbcType=INTEGER}
</if>
<if test="industryIDs">
AND q.IndustryIDs =#{industryID,jdbcType=VARCHAR}
</if>
ORDER BY p.TemplateGroupID, p.OrderIndex
</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