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

add the code for the rule enginee config module

parent 02ab46e3
......@@ -334,15 +334,23 @@
<table tableName="KeyValueConfig" domainObjectName="KeyValueConfig">
<property name="useActualColumnNames" value="true" />
<property name="ignoreQualifiersAtRuntime" value="true" />
<columnOverride column="KeyCode" javaType="java.lang.String" jdbcType="VARCHAR" />
<columnOverride column="Name" javaType="java.lang.String" jdbcType="VARCHAR" />
<columnOverride column="Formula" javaType="java.lang.String" jdbcType="VARCHAR" />
<columnOverride column="Description" javaType="java.lang.String" jdbcType="VARCHAR" />
<columnOverride column="KeyCode" javaType="java.lang.String"
jdbcType="VARCHAR" />
<columnOverride column="Name" javaType="java.lang.String"
jdbcType="VARCHAR" />
<columnOverride column="Formula" javaType="java.lang.String"
jdbcType="VARCHAR" />
<columnOverride column="Description" javaType="java.lang.String"
jdbcType="VARCHAR" />
</table>
<table tableName="TemplateGroup" domainObjectName="TemplateGroup">
<property name="useActualColumnNames" value="true" />
<property name="ignoreQualifiersAtRuntime" value="true" />
<columnOverride column="IsSystemType" javaType="Boolean" />
</table>
<table tableName="KeyValueReference" domainObjectName="KeyValueReference">
<property name="useActualColumnNames" value="true" />
<property name="ignoreQualifiersAtRuntime" value="true" />
</table>
</context>
</generatorConfiguration>
\ No newline at end of file
package pwc.taxtech.atms.common;
public enum ApplyScope {
FinancialStatement(1),
TaxReturn (2),
AnalyticsModel(3);
private int value;
ApplyScope(int value) {
this.value = value;
}
public Integer value() {
return value;
}
public static String getName(int value) {
for(ApplyScope module:ApplyScope.values()) {
if(module.value() == value) {
return module.name();
}
}
return null;
}
}
package pwc.taxtech.atms.controller;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.ApiOperation;
import pwc.taxtech.atms.dto.KeyValueConfigDisplayDto;
import pwc.taxtech.atms.service.KeyValueConfigService;
@RestController
@RequestMapping("/api/v1/keyValueConfig")
public class KeyValueConfigController {
private static final Logger logger = LoggerFactory.getLogger(EnterpriseAccountManagerController.class);
@Autowired
private KeyValueConfigService keyValueConfigService;
@ApiOperation(value="get keyValueConfig")
@RequestMapping(value="",method=RequestMethod.GET)
public @ResponseBody List<KeyValueConfigDisplayDto> Get(){
return keyValueConfigService.Get();
}
}
package pwc.taxtech.atms.controller;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.ApiOperation;
import pwc.taxtech.atms.entitiy.TemplateGroup;
import pwc.taxtech.atms.service.TemplateGroupService;
@RestController
@RequestMapping("/api/v1/templateGroup/")
public class TemplateGroupController {
private static final Logger logger = LoggerFactory.getLogger(TemplateGroupController.class);
@Autowired
TemplateGroupService templateGroupService;
@ApiOperation(value = "")
@RequestMapping(value = "getall", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody List<TemplateGroup> Get() {
logger.debug("TemplateGroupController Get");
return templateGroupService.Get();
}
}
......@@ -105,4 +105,6 @@ public interface KeyValueConfigMapper extends MyMapper {
* @mbg.generated
*/
int updateByPrimaryKey(KeyValueConfig record);
List<KeyValueConfig> SelectKeyValueConfigsByOrderByCreateTime();
}
\ No newline at end of file
package pwc.taxtech.atms.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.MyMapper;
import pwc.taxtech.atms.entitiy.KeyValueReference;
import pwc.taxtech.atms.entitiy.KeyValueReferenceExample;
@Mapper
public interface KeyValueReferenceMapper extends MyMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table KeyValueReference
*
* @mbg.generated
*/
long countByExample(KeyValueReferenceExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table KeyValueReference
*
* @mbg.generated
*/
int deleteByExample(KeyValueReferenceExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table KeyValueReference
*
* @mbg.generated
*/
int deleteByPrimaryKey(String ID);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table KeyValueReference
*
* @mbg.generated
*/
int insert(KeyValueReference record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table KeyValueReference
*
* @mbg.generated
*/
int insertSelective(KeyValueReference record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table KeyValueReference
*
* @mbg.generated
*/
List<KeyValueReference> selectByExampleWithRowbounds(KeyValueReferenceExample example, RowBounds rowBounds);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table KeyValueReference
*
* @mbg.generated
*/
List<KeyValueReference> selectByExample(KeyValueReferenceExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table KeyValueReference
*
* @mbg.generated
*/
KeyValueReference selectByPrimaryKey(String ID);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table KeyValueReference
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") KeyValueReference record, @Param("example") KeyValueReferenceExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table KeyValueReference
*
* @mbg.generated
*/
int updateByExample(@Param("record") KeyValueReference record, @Param("example") KeyValueReferenceExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table KeyValueReference
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(KeyValueReference record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table KeyValueReference
*
* @mbg.generated
*/
int updateByPrimaryKey(KeyValueReference record);
}
\ No newline at end of file
package pwc.taxtech.atms.dto;
import java.util.List;
import java.util.Map;
public class KeyValueConfigDisplayDto {
private String ID;
private String KeyCode;
private String Name;
private String Formula;
private String Description;
private String ScopeSummary;
private String ServiceTypes;
private String Industrys;
private List<String> ServiceTypeIds;
private List<String> IndustryIds;
private Integer KeyValueType;
private String DataSource;
private Map<Integer, Integer> ScopeCount;
public String getID() {
return ID;
}
public void setID(String ID) {
this.ID = ID;
}
public String getKeyCode() {
return KeyCode;
}
public void setKeyCode(String keyCode) {
KeyCode = keyCode;
}
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
public String getFormula() {
return Formula;
}
public void setFormula(String formula) {
Formula = formula;
}
public String getDescription() {
return Description;
}
public void setDescription(String description) {
Description = description;
}
public String getScopeSummary() {
return ScopeSummary;
}
public void setScopeSummary(String scopeSummary) {
ScopeSummary = scopeSummary;
}
public String getServiceTypes() {
return ServiceTypes;
}
public void setServiceTypes(String serviceTypes) {
ServiceTypes = serviceTypes;
}
public String getIndustrys() {
return Industrys;
}
public void setIndustrys(String industrys) {
Industrys = industrys;
}
public List<String> getServiceTypeIds() {
return ServiceTypeIds;
}
public void setServiceTypeIds(List<String> serviceTypeIds) {
ServiceTypeIds = serviceTypeIds;
}
public List<String> getIndustryIds() {
return IndustryIds;
}
public void setIndustryIds(List<String> industryIds) {
IndustryIds = industryIds;
}
public Integer getKeyValueType() {
return KeyValueType;
}
public void setKeyValueType(Integer keyValueType) {
KeyValueType = keyValueType;
}
public String getDataSource() {
return DataSource;
}
public void setDataSource(String dataSource) {
DataSource = dataSource;
}
public Map<Integer, Integer> getScopeCount() {
return ScopeCount;
}
public void setScopeCount(Map<Integer, Integer> scopeCount) {
ScopeCount = scopeCount;
}
}
package pwc.taxtech.atms.entitiy;
import java.io.Serializable;
/**
*
* This class was generated by MyBatis Generator.
* This class corresponds to the database table KeyValueReference
*
* @mbg.generated do_not_delete_during_merge
*/
public class KeyValueReference implements Serializable {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column KeyValueReference.ID
*
* @mbg.generated
*/
private String ID;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column KeyValueReference.KeyValueConfigID
*
* @mbg.generated
*/
private String keyValueConfigID;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column KeyValueReference.Scope
*
* @mbg.generated
*/
private Integer scope;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column KeyValueReference.CellTemplateID
*
* @mbg.generated
*/
private String cellTemplateID;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column KeyValueReference.ModelID
*
* @mbg.generated
*/
private String modelID;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column KeyValueReference.OrganizationID
*
* @mbg.generated
*/
private String organizationID;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column KeyValueReference.IndustryID
*
* @mbg.generated
*/
private String industryID;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table KeyValueReference
*
* @mbg.generated
*/
private static final long serialVersionUID = 1L;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column KeyValueReference.ID
*
* @return the value of KeyValueReference.ID
*
* @mbg.generated
*/
public String getID() {
return ID;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column KeyValueReference.ID
*
* @param ID the value for KeyValueReference.ID
*
* @mbg.generated
*/
public void setID(String ID) {
this.ID = ID == null ? null : ID.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column KeyValueReference.KeyValueConfigID
*
* @return the value of KeyValueReference.KeyValueConfigID
*
* @mbg.generated
*/
public String getKeyValueConfigID() {
return keyValueConfigID;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column KeyValueReference.KeyValueConfigID
*
* @param keyValueConfigID the value for KeyValueReference.KeyValueConfigID
*
* @mbg.generated
*/
public void setKeyValueConfigID(String keyValueConfigID) {
this.keyValueConfigID = keyValueConfigID == null ? null : keyValueConfigID.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column KeyValueReference.Scope
*
* @return the value of KeyValueReference.Scope
*
* @mbg.generated
*/
public Integer getScope() {
return scope;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column KeyValueReference.Scope
*
* @param scope the value for KeyValueReference.Scope
*
* @mbg.generated
*/
public void setScope(Integer scope) {
this.scope = scope;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column KeyValueReference.CellTemplateID
*
* @return the value of KeyValueReference.CellTemplateID
*
* @mbg.generated
*/
public String getCellTemplateID() {
return cellTemplateID;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column KeyValueReference.CellTemplateID
*
* @param cellTemplateID the value for KeyValueReference.CellTemplateID
*
* @mbg.generated
*/
public void setCellTemplateID(String cellTemplateID) {
this.cellTemplateID = cellTemplateID == null ? null : cellTemplateID.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column KeyValueReference.ModelID
*
* @return the value of KeyValueReference.ModelID
*
* @mbg.generated
*/
public String getModelID() {
return modelID;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column KeyValueReference.ModelID
*
* @param modelID the value for KeyValueReference.ModelID
*
* @mbg.generated
*/
public void setModelID(String modelID) {
this.modelID = modelID == null ? null : modelID.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column KeyValueReference.OrganizationID
*
* @return the value of KeyValueReference.OrganizationID
*
* @mbg.generated
*/
public String getOrganizationID() {
return organizationID;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column KeyValueReference.OrganizationID
*
* @param organizationID the value for KeyValueReference.OrganizationID
*
* @mbg.generated
*/
public void setOrganizationID(String organizationID) {
this.organizationID = organizationID == null ? null : organizationID.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column KeyValueReference.IndustryID
*
* @return the value of KeyValueReference.IndustryID
*
* @mbg.generated
*/
public String getIndustryID() {
return industryID;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column KeyValueReference.IndustryID
*
* @param industryID the value for KeyValueReference.IndustryID
*
* @mbg.generated
*/
public void setIndustryID(String industryID) {
this.industryID = industryID == null ? null : industryID.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table KeyValueReference
*
* @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(", keyValueConfigID=").append(keyValueConfigID);
sb.append(", scope=").append(scope);
sb.append(", cellTemplateID=").append(cellTemplateID);
sb.append(", modelID=").append(modelID);
sb.append(", organizationID=").append(organizationID);
sb.append(", industryID=").append(industryID);
sb.append("]");
return sb.toString();
}
}
\ No newline at end of file
package pwc.taxtech.atms.service;
import java.util.List;
import pwc.taxtech.atms.dto.KeyValueConfigDisplayDto;
public interface KeyValueConfigService {
List<KeyValueConfigDisplayDto> Get();
}
package pwc.taxtech.atms.service;
import java.util.List;
import pwc.taxtech.atms.entitiy.TemplateGroup;
public interface TemplateGroupService {
List<TemplateGroup> Get();
}
......@@ -20,6 +20,8 @@ import pwc.taxtech.atms.dao.EnterpriseAccountMapper;
import pwc.taxtech.atms.dao.EnterpriseAccountSetMapper;
import pwc.taxtech.atms.dao.EnterpriseAccountSetOrgMapper;
import pwc.taxtech.atms.dao.IndustryMapper;
import pwc.taxtech.atms.dao.KeyValueConfigMapper;
import pwc.taxtech.atms.dao.KeyValueReferenceMapper;
import pwc.taxtech.atms.dao.MailQueueMapper;
import pwc.taxtech.atms.dao.MenuMapper;
import pwc.taxtech.atms.dao.MyStatisticAttributeMapper;
......@@ -42,6 +44,7 @@ import pwc.taxtech.atms.dao.StockMapper;
import pwc.taxtech.atms.dao.TaxPayerReportRuleMapper;
import pwc.taxtech.atms.dao.TaxRuleSettingMapper;
import pwc.taxtech.atms.dao.TaxRuleSettingOrganizationMapper;
import pwc.taxtech.atms.dao.TemplateGroupMapper;
import pwc.taxtech.atms.dao.UserDimensionValueMapper;
import pwc.taxtech.atms.dao.UserDimensionValueOrgMapper;
import pwc.taxtech.atms.dao.UserDimensionValueRoleMapper;
......@@ -147,4 +150,10 @@ public class AbstractService {
protected TaxRuleSettingOrganizationMapper taxRuleSettingOrganizationMapper;
@Autowired
protected OrganizationServiceTemplateGroupMapper organizationServiceTemplateGroupMapper;
@Autowired
protected TemplateGroupMapper templateGroupMapper;
@Autowired
protected KeyValueConfigMapper keyValueConfigMapper;
@Autowired
protected KeyValueReferenceMapper keyValueReferenceMapper;
}
package pwc.taxtech.atms.service.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import com.alibaba.druid.util.StringUtils;
import pwc.taxtech.atms.common.ApplyScope;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.dto.KeyValueConfigDisplayDto;
import pwc.taxtech.atms.entitiy.IndustryExample;
import pwc.taxtech.atms.entitiy.KeyValueConfig;
import pwc.taxtech.atms.entitiy.KeyValueReference;
import pwc.taxtech.atms.entitiy.KeyValueReferenceExample;
import pwc.taxtech.atms.entitiy.ServiceTypeExample;
import pwc.taxtech.atms.service.KeyValueConfigService;
@Service
public class KeyValueConfigServiceImpl extends AbstractService implements KeyValueConfigService {
private static final Logger logger = LoggerFactory.getLogger(KeyValueConfigServiceImpl.class);
@Override
public List<KeyValueConfigDisplayDto> Get() {
List<KeyValueConfig> list = keyValueConfigMapper.SelectKeyValueConfigsByOrderByCreateTime();
List<KeyValueConfigDisplayDto> result = new ArrayList<KeyValueConfigDisplayDto>();
if (list.size() > 0) {
Map<String, String> industryList = new HashMap<String, String>();
industryMapper.selectByExample(new IndustryExample()).stream()
.map(item -> industryList.put(item.getID(), item.getName())).collect(Collectors.toList());
Map<String, String> serviceType = new HashMap<String, String>();
serviceTypeMapper.selectByExample(new ServiceTypeExample()).stream()
.map(item -> serviceType.put(item.getID(), item.getName())).collect(Collectors.toList());
List<KeyValueReference> scopes = keyValueReferenceMapper.selectByExample(new KeyValueReferenceExample());
for (KeyValueConfig keyValueConfig : list) {
KeyValueConfigDisplayDto dtoObj = new KeyValueConfigDisplayDto();
CommonUtils.copyProperties(keyValueConfig, dtoObj);
dtoObj.setServiceTypes(GetNamesByIDs(keyValueConfig.getServiceTypeIDs(), serviceType));
dtoObj.setIndustrys(GetNamesByIDs(keyValueConfig.getIndustryIDs(), industryList));
dtoObj.setIndustryIds(Arrays.asList(keyValueConfig.getIndustryIDs().split(",")));
dtoObj.setServiceTypeIds(Arrays.asList(keyValueConfig.getServiceTypeIDs().split(",")));
List<KeyValueReference> selectScopeList = scopes.stream()
.filter(item -> item.getKeyValueConfigID() == item.getID()).collect(Collectors.toList());
List<Integer> selectScopes = selectScopeList.stream().map(item -> item.getScope()).distinct()
.collect(Collectors.toList());
Map<Integer, Integer> scopeCount = new HashMap<Integer,Integer>();
if(selectScopeList!=null&&selectScopeList.size()>0) {
for(Integer selectScope :selectScopes) {
Integer count = (int)(selectScopeList.stream().filter(a->a.getScope()==selectScope).count());
scopeCount.put(selectScope, count);
}
}
dtoObj.setScopeCount(scopeCount);
dtoObj.setScopeSummary(JointToString(selectScopes));
result.add(dtoObj);
}
}
return result;
}
private String JointToString(List<Integer> selectScopes) {
StringBuilder scopeBuilder = new StringBuilder();
for (Integer selectScope : selectScopes) {
scopeBuilder.append(ApplyScope.getName(selectScope)).append(",");
}
return scopeBuilder.length() > 0 ? scopeBuilder.toString().substring(0, scopeBuilder.length() - 2) : "";
}
private String GetNamesByIDs(String source, Map<String, String> queryList) {
if (StringUtils.isEmpty(source)) {
return source;
}
String[] sArray = source.split(",");
List<String> sName = new ArrayList<String>();
for (String s : sArray) {
if (queryList.containsKey(s)) {
sName.add(queryList.get(s));
}
}
StringBuilder retStr = new StringBuilder();
sName.stream().forEach(s -> retStr.append(s + ","));
return retStr.toString().substring(0, retStr.length() - 2);
}
}
package pwc.taxtech.atms.service.impl;
import java.util.List;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.entitiy.TemplateGroup;
import pwc.taxtech.atms.entitiy.TemplateGroupExample;
import pwc.taxtech.atms.service.TemplateGroupService;
@Service
public class TemplateGroupServiceImpl extends AbstractService implements TemplateGroupService {
@Override
public List<TemplateGroup> Get() {
return templateGroupMapper.selectByExample(new TemplateGroupExample());
}
}
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