Commit 2dfb7248 authored by frank's avatar frank

Merge branch 'dev_frank' into 'dev'

add report config api CellConfig

See merge request root/atms!7
parents 362b79f8 5a08ef3b
...@@ -331,5 +331,24 @@ ...@@ -331,5 +331,24 @@
<property name="useActualColumnNames" value="true" /> <property name="useActualColumnNames" value="true" />
<property name="ignoreQualifiersAtRuntime" value="true" /> <property name="ignoreQualifiersAtRuntime" value="true" />
</table> </table>
<table tableName="CellTemplate" domainObjectName="CellTemplate">
<property name="useActualColumnNames" value="true"/>
<property name="ignoreQualifiersAtRuntime" value="true"/>
<columnOverride column="RowName" javaType="java.lang.String" jdbcType="VARCHAR"/>
<columnOverride column="ColumnName" javaType="java.lang.String" jdbcType="VARCHAR"/>
<columnOverride column="Comment" javaType="java.lang.String" jdbcType="VARCHAR"/>
</table>
<table tableName="CellTemplateConfig" domainObjectName="CellTemplateConfig">
<property name="useActualColumnNames" value="true"/>
<property name="ignoreQualifiersAtRuntime" value="true"/>
<columnOverride column="Formula" javaType="java.lang.String" jdbcType="VARCHAR"/>
<columnOverride column="FormulaDescription" javaType="java.lang.String" jdbcType="VARCHAR"/>
<columnOverride column="AccountCodes" javaType="java.lang.String" jdbcType="VARCHAR"/>
<columnOverride column="ModelIDs" javaType="java.lang.String" jdbcType="VARCHAR"/>
<columnOverride column="FormulaDataSource" javaType="java.lang.String" jdbcType="VARCHAR"/>
<columnOverride column="Validation" javaType="java.lang.String" jdbcType="VARCHAR"/>
<columnOverride column="ValidationDescription" javaType="java.lang.String" jdbcType="VARCHAR"/>
<columnOverride column="VoucherKeyword" javaType="java.lang.String" jdbcType="VARCHAR"/>
</table>
</context> </context>
</generatorConfiguration> </generatorConfiguration>
\ No newline at end of file
rem see http://www.mybatis.org/generator/running/runningFromCmdLine.html rem see http://www.mybatis.org/generator/running/runningFromCmdLine.html
cd /d %~dp0 cd /d %~dp0
call java -classpath .;./* org.mybatis.generator.api.ShellRunner -configfile generatorConfig.xml -overwrite -verbose -tables Cache call java -classpath .;./* org.mybatis.generator.api.ShellRunner -configfile generatorConfig.xml -overwrite -verbose -tables CellTemplateConfig
echo @@@@@@@@@@@ DONE @@@@@@@@@@@ echo @@@@@@@@@@@ DONE @@@@@@@@@@@
pause pause
package pwc.taxtech.atms.constant;
public final class Constant {
public static final String Comma = ",";
}
package pwc.taxtech.atms.constant.enums;
public enum CellDataSourceType {
/// <summary>
/// 公式(包含KeyValue)
/// </summary>
Formula (1),
/// <summary>
/// 凭证
/// </summary>
Voucher (2),
/// <summary>
/// 销项发票
/// </summary>
OutputInvoice (3),
/// <summary>
/// 进项发票
/// </summary>
InputInvoice (4),
/// <summary>
/// 海关发票
/// </summary>
CustomInvoice (5),
/// <summary>
/// 手工录入
/// </summary>
KeyIn (6),
/// <summary>
/// 关联模型
/// </summary>
RelatedModel (7),
/// <summary>
/// SAP日报
/// </summary>
SapDaily (8),
/// <summary>
/// 校验
/// </summary>
Validation (9);
private Integer code;
CellDataSourceType(Integer code) {
this.code = code;
}
public Integer getCode() {
return code;
}
}
package pwc.taxtech.atms.controller;
import org.apache.commons.lang3.StringUtils;
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.*;
import pwc.taxtech.atms.dto.CellTemplateConfigDto;
import pwc.taxtech.atms.service.CellTemplateService;
import java.util.Collections;
import java.util.List;
@RestController
@RequestMapping(value = "api/v1/celltemplate")
public class CellTemplateController {
private static final Logger logger = LoggerFactory.getLogger(AccountController.class);
@Autowired
CellTemplateService cellTemplateService;
@RequestMapping(value = "configList/{templateID}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
List<CellTemplateConfigDto> GetConfigList(@PathVariable String templateID) {
if(StringUtils.isEmpty(templateID)){
return Collections.emptyList();
}
try {
return cellTemplateService.GetCellConfigList(templateID);
} catch (Exception e) {
logger.error("GetCellConfigList",e);
}
return Collections.emptyList();
}
}
package pwc.taxtech.atms.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "api/v1/template")
public class TemplateController {
//todo:
//[Route("getTemplateJson")]
// [HttpGet]
// public IHttpActionResult GetTemplateJson(string templateID)
// {
// return this.Ok(templateService.GetTemplateJson(templateID));
// }
// [Route("get")]
// [HttpGet]
// public IHttpActionResult get(string templateGroupID, int? reportType)
// {
// return this.Ok(this.templateService.Get(templateGroupID, reportType));
// }
}
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.CellTemplateConfig;
import pwc.taxtech.atms.entitiy.CellTemplateConfigExample;
@Mapper
public interface CellTemplateConfigMapper extends MyMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplateConfig
*
* @mbg.generated
*/
long countByExample(CellTemplateConfigExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplateConfig
*
* @mbg.generated
*/
int deleteByExample(CellTemplateConfigExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplateConfig
*
* @mbg.generated
*/
int deleteByPrimaryKey(String ID);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplateConfig
*
* @mbg.generated
*/
int insert(CellTemplateConfig record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplateConfig
*
* @mbg.generated
*/
int insertSelective(CellTemplateConfig record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplateConfig
*
* @mbg.generated
*/
List<CellTemplateConfig> selectByExampleWithRowbounds(CellTemplateConfigExample example, RowBounds rowBounds);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplateConfig
*
* @mbg.generated
*/
List<CellTemplateConfig> selectByExample(CellTemplateConfigExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplateConfig
*
* @mbg.generated
*/
CellTemplateConfig selectByPrimaryKey(String ID);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplateConfig
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") CellTemplateConfig record, @Param("example") CellTemplateConfigExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplateConfig
*
* @mbg.generated
*/
int updateByExample(@Param("record") CellTemplateConfig record, @Param("example") CellTemplateConfigExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplateConfig
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(CellTemplateConfig record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplateConfig
*
* @mbg.generated
*/
int updateByPrimaryKey(CellTemplateConfig record);
List<CellTemplateConfig> getCellTemplateConfigByTemplateID(@Param("templateID") String templateID);
}
\ 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.CellTemplate;
import pwc.taxtech.atms.entitiy.CellTemplateExample;
@Mapper
public interface CellTemplateMapper extends MyMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplate
*
* @mbg.generated
*/
long countByExample(CellTemplateExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplate
*
* @mbg.generated
*/
int deleteByExample(CellTemplateExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplate
*
* @mbg.generated
*/
int deleteByPrimaryKey(String ID);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplate
*
* @mbg.generated
*/
int insert(CellTemplate record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplate
*
* @mbg.generated
*/
int insertSelective(CellTemplate record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplate
*
* @mbg.generated
*/
List<CellTemplate> selectByExampleWithRowbounds(CellTemplateExample example, RowBounds rowBounds);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplate
*
* @mbg.generated
*/
List<CellTemplate> selectByExample(CellTemplateExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplate
*
* @mbg.generated
*/
CellTemplate selectByPrimaryKey(String ID);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplate
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") CellTemplate record, @Param("example") CellTemplateExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplate
*
* @mbg.generated
*/
int updateByExample(@Param("record") CellTemplate record, @Param("example") CellTemplateExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplate
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(CellTemplate record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table CellTemplate
*
* @mbg.generated
*/
int updateByPrimaryKey(CellTemplate record);
}
\ No newline at end of file
package pwc.taxtech.atms.dto;
import java.util.List;
public class CellTemplateConfigDto {
private String CellTemplateID;
private String TemplateID;
private int RowIndex;
private String RowName;
private int ColumnIndex;
private String ColumnName;
private Integer DataType;
private Integer IsReadOnly;
private boolean HasFormula;
private String Formula;
private String ParsedFormula;
private String FormulaDescription;
private boolean HasVoucher;
private List<String> AccountCodes;
private boolean HasInvoice;
private Integer InvoiceType;
private List<String> TaxRate;
private boolean HasKeyIn;
private String Creator;
private String Updater;
private Integer InvoiceAmountType;
private boolean HasModel;
private List<String> ModelIDs;
private List<Integer> InvoiceCategory;
private String FormulaDataSource;
private boolean HasValidation;
private String Validation;
private String ParsedValidation;
private String ValidationDescription;
private String VoucherKeyword;
public String getCellTemplateID() {
return CellTemplateID;
}
public void setCellTemplateID(String cellTemplateID) {
CellTemplateID = cellTemplateID;
}
public String getTemplateID() {
return TemplateID;
}
public void setTemplateID(String templateID) {
TemplateID = templateID;
}
public int getRowIndex() {
return RowIndex;
}
public void setRowIndex(int rowIndex) {
RowIndex = rowIndex;
}
public String getRowName() {
return RowName;
}
public void setRowName(String rowName) {
RowName = rowName;
}
public int getColumnIndex() {
return ColumnIndex;
}
public void setColumnIndex(int columnIndex) {
ColumnIndex = columnIndex;
}
public String getColumnName() {
return ColumnName;
}
public void setColumnName(String columnName) {
ColumnName = columnName;
}
public Integer getDataType() {
return DataType;
}
public void setDataType(Integer dataType) {
DataType = dataType;
}
public Integer getIsReadOnly() {
return IsReadOnly;
}
public void setIsReadOnly(Integer isReadOnly) {
IsReadOnly = isReadOnly;
}
public boolean isHasFormula() {
return HasFormula;
}
public void setHasFormula(boolean hasFormula) {
HasFormula = hasFormula;
}
public String getFormula() {
return Formula;
}
public void setFormula(String formula) {
Formula = formula;
}
public String getParsedFormula() {
return ParsedFormula;
}
public void setParsedFormula(String parsedFormula) {
ParsedFormula = parsedFormula;
}
public String getFormulaDescription() {
return FormulaDescription;
}
public void setFormulaDescription(String formulaDescription) {
FormulaDescription = formulaDescription;
}
public boolean isHasVoucher() {
return HasVoucher;
}
public void setHasVoucher(boolean hasVoucher) {
HasVoucher = hasVoucher;
}
public List<String> getAccountCodes() {
return AccountCodes;
}
public void setAccountCodes(List<String> accountCodes) {
AccountCodes = accountCodes;
}
public boolean isHasInvoice() {
return HasInvoice;
}
public void setHasInvoice(boolean hasInvoice) {
HasInvoice = hasInvoice;
}
public Integer getInvoiceType() {
return InvoiceType;
}
public void setInvoiceType(Integer invoiceType) {
InvoiceType = invoiceType;
}
public List<String> getTaxRate() {
return TaxRate;
}
public void setTaxRate(List<String> taxRate) {
TaxRate = taxRate;
}
public boolean isHasKeyIn() {
return HasKeyIn;
}
public void setHasKeyIn(boolean hasKeyIn) {
HasKeyIn = hasKeyIn;
}
public String getCreator() {
return Creator;
}
public void setCreator(String creator) {
Creator = creator;
}
public String getUpdater() {
return Updater;
}
public void setUpdater(String updater) {
Updater = updater;
}
public Integer getInvoiceAmountType() {
return InvoiceAmountType;
}
public void setInvoiceAmountType(Integer invoiceAmountType) {
InvoiceAmountType = invoiceAmountType;
}
public boolean isHasModel() {
return HasModel;
}
public void setHasModel(boolean hasModel) {
HasModel = hasModel;
}
public List<String> getModelIDs() {
return ModelIDs;
}
public void setModelIDs(List<String> modelIDs) {
ModelIDs = modelIDs;
}
public List<Integer> getInvoiceCategory() {
return InvoiceCategory;
}
public void setInvoiceCategory(List<Integer> invoiceCategory) {
InvoiceCategory = invoiceCategory;
}
public String getFormulaDataSource() {
return FormulaDataSource;
}
public void setFormulaDataSource(String formulaDataSource) {
FormulaDataSource = formulaDataSource;
}
public boolean isHasValidation() {
return HasValidation;
}
public void setHasValidation(boolean hasValidation) {
HasValidation = hasValidation;
}
public String getValidation() {
return Validation;
}
public void setValidation(String validation) {
Validation = validation;
}
public String getParsedValidation() {
return ParsedValidation;
}
public void setParsedValidation(String parsedValidation) {
ParsedValidation = parsedValidation;
}
public String getValidationDescription() {
return ValidationDescription;
}
public void setValidationDescription(String validationDescription) {
ValidationDescription = validationDescription;
}
public String getVoucherKeyword() {
return VoucherKeyword;
}
public void setVoucherKeyword(String voucherKeyword) {
VoucherKeyword = voucherKeyword;
}
}
package pwc.taxtech.atms.service;
import pwc.taxtech.atms.dto.CellTemplateConfigDto;
import java.util.List;
public interface CellTemplateService {
List<CellTemplateConfigDto> GetCellConfigList(String templateID);
}
...@@ -6,53 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -6,53 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import pwc.taxtech.atms.common.AtmsApiSettings; import pwc.taxtech.atms.common.AtmsApiSettings;
import pwc.taxtech.atms.common.AuthUserHelper; import pwc.taxtech.atms.common.AuthUserHelper;
import pwc.taxtech.atms.dao.AccountMapper; import pwc.taxtech.atms.dao.*;
import pwc.taxtech.atms.dao.AccountMappingMapper;
import pwc.taxtech.atms.dao.AreaMapper;
import pwc.taxtech.atms.dao.AreaRegionMapper;
import pwc.taxtech.atms.dao.BusinessUnitMapper;
import pwc.taxtech.atms.dao.CustomerMapper;
import pwc.taxtech.atms.dao.DictionaryMapper;
import pwc.taxtech.atms.dao.DimensionMapper;
import pwc.taxtech.atms.dao.DimensionValueMapper;
import pwc.taxtech.atms.dao.DimensionValueOrgMapper;
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.ModelConfigMapper;
import pwc.taxtech.atms.dao.MyStatisticAttributeMapper;
import pwc.taxtech.atms.dao.MyUserMapper;
import pwc.taxtech.atms.dao.OperationLogBasicDataMapper;
import pwc.taxtech.atms.dao.OperationLogEnterPriseMapper;
import pwc.taxtech.atms.dao.OrganizationMapper;
import pwc.taxtech.atms.dao.OrganizationServiceTemplateGroupMapper;
import pwc.taxtech.atms.dao.OrganizationStructureMapper;
import pwc.taxtech.atms.dao.PermissionMapper;
import pwc.taxtech.atms.dao.RegionMapper;
import pwc.taxtech.atms.dao.RoleCategoryMapper;
import pwc.taxtech.atms.dao.RoleMapper;
import pwc.taxtech.atms.dao.RolePermissionMapper;
import pwc.taxtech.atms.dao.ServiceTypeMapper;
import pwc.taxtech.atms.dao.StandardAccountMapper;
import pwc.taxtech.atms.dao.StatisticAttributeDimensionMapper;
import pwc.taxtech.atms.dao.StatisticAttributeMapper;
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;
import pwc.taxtech.atms.dao.UserMapper;
import pwc.taxtech.atms.dao.UserOrganizationMapper;
import pwc.taxtech.atms.dao.UserOrganizationRoleMapper;
import pwc.taxtech.atms.dao.UserRoleMapper;
import pwc.taxtech.atms.service.OperationLogService; import pwc.taxtech.atms.service.OperationLogService;
public class AbstractService { public class AbstractService {
...@@ -159,4 +113,8 @@ public class AbstractService { ...@@ -159,4 +113,8 @@ public class AbstractService {
protected KeyValueReferenceMapper keyValueReferenceMapper; protected KeyValueReferenceMapper keyValueReferenceMapper;
@Autowired @Autowired
protected ModelConfigMapper modelConfigMapper; protected ModelConfigMapper modelConfigMapper;
@Autowired
protected CellTemplateMapper cellTemplateMapper;
@Autowired
protected CellTemplateConfigMapper cellTemplateConfigMapper;
} }
package pwc.taxtech.atms.service.impl;
import org.apache.commons.lang3.StringUtils;
import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.constant.enums.CellDataSourceType;
import pwc.taxtech.atms.dto.CellTemplateConfigDto;
import pwc.taxtech.atms.entitiy.CellTemplate;
import pwc.taxtech.atms.entitiy.CellTemplateConfig;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
public final class CellConfigTranslater {
public static CellTemplateConfigDto GetConfigDto(CellTemplate template, List<CellTemplateConfig> configList) {
if (template == null) {
return null;
}
CellTemplateConfigDto cellTemplateConfigDto = GetConfigDto(template.getID(), template.getReportTemplateID(), template.getRowIndex(), template.getRowName(), template.getColumnIndex(),
template.getColumnName(), template.getDataType(), template.getIsReadOnly(), template.getComment(), configList);
return cellTemplateConfigDto;
}
public static CellTemplateConfigDto GetConfigDto(String configID, String templateID, int rowIndex, String rowName, int columnIndex,
String columnName, Integer dataType, Integer isReadOnly, String description, List<CellTemplateConfig> configList) {
if (configList == null) {
return null;
}
CellTemplateConfigDto cellTemplateConfigDto = new CellTemplateConfigDto();
cellTemplateConfigDto.setCellTemplateID(configID);
cellTemplateConfigDto.setTemplateID(templateID);
cellTemplateConfigDto.setRowIndex(rowIndex);
cellTemplateConfigDto.setRowName(rowName);
cellTemplateConfigDto.setColumnIndex(columnIndex);
cellTemplateConfigDto.setColumnName(columnName);
cellTemplateConfigDto.setDataType(dataType);
cellTemplateConfigDto.setIsReadOnly(isReadOnly);
cellTemplateConfigDto.setFormulaDescription(description);
Optional<CellTemplateConfig> formulaItem = configList.stream().filter(a -> a.getDataSourceType().equals(CellDataSourceType.valueOf("Formula"))).findFirst();
if (formulaItem != null) {
cellTemplateConfigDto.setHasFormula(true);
cellTemplateConfigDto.setFormula(formulaItem.get().getFormula());
if (StringUtils.isEmpty(cellTemplateConfigDto.getFormulaDescription())
&& !StringUtils.isEmpty(formulaItem.get().getFormulaDescription())) {
cellTemplateConfigDto.setFormulaDescription(formulaItem.get().getFormulaDescription());
}
cellTemplateConfigDto.setFormulaDataSource(formulaItem.get().getFormulaDataSource());
cellTemplateConfigDto.setCellTemplateID(formulaItem.get().getCellTemplateID());
}
Optional<CellTemplateConfig> voucherItem = configList.stream().filter(x -> x.getDataSourceType().equals(CellDataSourceType.valueOf("Voucher"))).findFirst();
if (voucherItem != null) {
cellTemplateConfigDto.setHasVoucher(true);
cellTemplateConfigDto.setVoucherKeyword(voucherItem.get().getVoucherKeyword() == null ? "" : voucherItem.get().getVoucherKeyword());
if (!StringUtils.isEmpty(voucherItem.get().getAccountCodes())) {
cellTemplateConfigDto.setAccountCodes(GetList(voucherItem.get().getAccountCodes()));
}
}
Optional<CellTemplateConfig> invoiceItem = configList.stream().filter(x -> x.getDataSourceType().equals(CellDataSourceType.valueOf("OutputInvoice")) || x.getDataSourceType().equals(CellDataSourceType.valueOf("InputInvoice")) || x.getDataSourceType().equals(CellDataSourceType.valueOf("CustomInvoice"))).findFirst();
if (invoiceItem != null) {
cellTemplateConfigDto.setHasInvoice(true);
cellTemplateConfigDto.setInvoiceType(invoiceItem.get().getInvoiceType());
cellTemplateConfigDto.setInvoiceAmountType(invoiceItem.get().getInvoiceAmountType());
if (!StringUtils.isEmpty(invoiceItem.get().getTaxRate())) {
cellTemplateConfigDto.setTaxRate(GetList(invoiceItem.get().getTaxRate()));
}
if (!StringUtils.isEmpty(invoiceItem.get().getInvoiceCategory())) {
List<String> invoiceCategoryStrs = GetList(invoiceItem.get().getInvoiceCategory());
List<Integer> ints = new ArrayList<>();
for (String categoryStr : invoiceCategoryStrs) {
int categoryVal;
categoryVal = Integer.parseInt(categoryStr);
ints.add(categoryVal);
}
cellTemplateConfigDto.setInvoiceCategory(ints);
}
}
Optional<CellTemplateConfig> keyInItem = configList.stream().filter(x -> x.getDataSourceType().equals(CellDataSourceType.valueOf("KeyIn"))).findFirst();
if (keyInItem != null) {
cellTemplateConfigDto.setHasKeyIn(true);
}
Optional<CellTemplateConfig> modelItem = configList.stream().filter(x -> x.getDataSourceType().equals(CellDataSourceType.valueOf("RelatedModel"))).findFirst();
if (modelItem != null) {
cellTemplateConfigDto.setHasModel(true);
cellTemplateConfigDto.setModelIDs(GetList(modelItem.get().getModelIDs()));
}
Optional<CellTemplateConfig> validationItem = configList.stream().filter(x -> x.getDataSourceType().equals(CellDataSourceType.valueOf("Validation"))).findFirst();
if (validationItem != null) {
cellTemplateConfigDto.setHasValidation(true);
cellTemplateConfigDto.setValidation(validationItem.get().getValidation());
cellTemplateConfigDto.setValidationDescription(validationItem.get().getValidationDescription());
cellTemplateConfigDto.setCellTemplateID(validationItem.get().getCellTemplateID());
}
return cellTemplateConfigDto;
}
private static List<String> GetList(String joinString) {
if (StringUtils.isEmpty(joinString)) {
return null;
}
return Arrays.asList(joinString.split(Constant.Comma));
}
}
package pwc.taxtech.atms.service.impl;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dto.CellTemplateConfigDto;
import pwc.taxtech.atms.entitiy.CellTemplate;
import pwc.taxtech.atms.entitiy.CellTemplateConfig;
import pwc.taxtech.atms.entitiy.CellTemplateExample;
import pwc.taxtech.atms.service.CellTemplateService;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class CellTemplateServiceImpl extends AbstractService implements CellTemplateService {
@Override
public List<CellTemplateConfigDto> GetCellConfigList(String templateID) {
List<CellTemplateConfigDto> result = new ArrayList<>();
CellTemplateExample example = new CellTemplateExample();
example.createCriteria().andReportTemplateIDEqualTo(templateID);
List<CellTemplate> cellTemplateList = cellTemplateMapper.selectByExample(example);
List<CellTemplateConfig> configList = cellTemplateConfigMapper.getCellTemplateConfigByTemplateID(templateID);
if (cellTemplateList.isEmpty()) {
return result;
}
for (CellTemplate x : cellTemplateList) {
result.add(GetConfigDto(x, configList.stream().filter(a -> a.getCellTemplateID().equalsIgnoreCase(x.getID())).collect(Collectors.toList())));
}
return result;
}
private CellTemplateConfigDto GetConfigDto(CellTemplate cellTemplate, List<CellTemplateConfig> configList) {
CellTemplateConfigDto cellTemplateConfigDto = CellConfigTranslater.GetConfigDto(cellTemplate, configList);
cellTemplateConfigDto.setCellTemplateID(cellTemplate.getID());
cellTemplateConfigDto.setTemplateID(cellTemplate.getReportTemplateID());
cellTemplateConfigDto.setRowIndex(cellTemplate.getRowIndex());
cellTemplateConfigDto.setRowName(cellTemplate.getRowName());
cellTemplateConfigDto.setColumnIndex(cellTemplate.getColumnIndex());
cellTemplateConfigDto.setColumnName(cellTemplate.getColumnName());
cellTemplateConfigDto.setDataType(cellTemplate.getDataType());
cellTemplateConfigDto.setIsReadOnly(cellTemplate.getIsReadOnly());
cellTemplateConfigDto.setFormulaDescription(cellTemplate.getComment());
return cellTemplateConfigDto;
}
}
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