Commit 13792da2 authored by neo's avatar neo

[DEL] delete single methond service

parent ee2fc699
package pwc.taxtech.atms.controller;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.io.FileUtils;
import org.joda.time.DateTime;
import org.nutz.lang.Lang;
......@@ -23,31 +15,39 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import io.swagger.annotations.ApiOperation;
import pwc.taxtech.atms.exception.ApplicationException;
import pwc.taxtech.atms.common.CommonConstants;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.message.ErrorMessage;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.datainit.DataInitDto;
import pwc.taxtech.atms.dto.datainit.DataInitMsgDto;
import pwc.taxtech.atms.service.DataInitService;
import pwc.taxtech.atms.exception.ApplicationException;
import pwc.taxtech.atms.service.impl.DataInitServiceImpl;
import pwc.taxtech.atms.service.impl.FileService;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@RestController
@RequestMapping("api/v1/init")
public class DataInitController {
private static final Logger logger = LoggerFactory.getLogger(DataInitController.class);
@Autowired private FileService fileService;
@Autowired private DataInitService dataInitService;
@Autowired
private FileService fileService;
@Autowired
private DataInitServiceImpl dataInitService;
@ApiOperation(value = "Download basic data initialization template")
@RequestMapping(value = { "/downloadTemplate" }, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RequestMapping(value = {"/downloadTemplate"}, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public void downloadTemplate(HttpServletResponse response) {
String filePath;
File templateFile = null;
InputStream inputStream = null;
......@@ -56,51 +56,47 @@ public class DataInitController {
templateFile = new File(filePath + CommonConstants.BasicDataTemplate);
inputStream = new BufferedInputStream(new FileInputStream(templateFile));
String customFileName = CommonConstants.BasicDataFileName + DateTime.now().toString("yyyyMMddHHmmss") + ".xlsx";//客户端保存的文件名
response.setHeader("Content-Disposition", String.format("inline; filename=\"" + customFileName +"\""));
response.setHeader("Content-Disposition", String.format("inline; filename=\"" + customFileName + "\""));
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
FileCopyUtils.copy(inputStream, response.getOutputStream());
}
catch (FileNotFoundException e) {
} catch (FileNotFoundException e) {
logger.error("Template file not found. Template file should be located at " + CommonConstants.BasicDataTemplate);
throw new ApplicationException("Tempate file not found.");
}
catch (Exception e) {
} catch (Exception e) {
logger.error("Error downloading template file " + CommonConstants.BasicDataFileName + ".xlsx", e);
throw new ApplicationException("Error downloading template file " + CommonConstants.BasicDataFileName + ".xlsx", e);
}
finally {
} finally {
try {
templateFile = null;
if (inputStream!=null) {
if (inputStream != null) {
inputStream.close();
}
}
catch (Exception e) {
logger.error("Error closing inputstream. ",e);
}
finally {
} catch (Exception e) {
logger.error("Error closing inputstream. ", e);
} finally {
inputStream = null;
}
}
}
@ApiOperation(value = "Upload initial data")
@RequestMapping(value = { "/Upload" }, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody Object uploadInitData(@RequestParam String action,
@RequestParam(value = "file", required = false) CommonsMultipartFile inputFile) {
@RequestMapping(value = {"/Upload"}, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
Object uploadInitData(@RequestParam String action,
@RequestParam(value = "file", required = false) CommonsMultipartFile inputFile) {
if (inputFile == null || inputFile.getSize() <= 0) {
return new OperationResultDto<>(false, ErrorMessage.NoFile);
}
logger.debug("file name: " + inputFile.getOriginalFilename());
InputStream inputStream = null;
try {
inputStream = inputFile.getInputStream();
inputStream = inputFile.getInputStream();
} catch (IOException e) {
throw Lang.wrapThrow(e);
}
//save file
String filePath = FileUtils.getTempDirectory().getAbsolutePath() + File.separator + "DataInit" + File.separator
+ CommonUtils.getUUID() + "_" + inputFile.getOriginalFilename();
......@@ -109,13 +105,13 @@ public class DataInitController {
if (saveResult.getResult() != null && !saveResult.getResult()) {
return saveResult;
}
DataInitDto dataInitDto = dataInitService.validateAndImportInitData(filePath);
DataInitMsgDto dataMsgDto = new DataInitMsgDto();
dataMsgDto.setErrorMsg(dataInitDto.getErrorMsgs());
dataMsgDto.setValidMsg(dataInitDto.getValidMsgs());
return dataMsgDto;
}
}
package pwc.taxtech.atms.controller;
import java.util.List;
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 pwc.taxtech.atms.entity.Industry;
import pwc.taxtech.atms.service.ProjectIndustryService;
import pwc.taxtech.atms.service.impl.ProjectIndustryServiceImpl;
import java.util.List;
@RestController
@RequestMapping(value = "api/v1/industry")
public class IndustryController {
@Autowired
ProjectIndustryService projectIndustryService;
@Autowired
ProjectIndustryServiceImpl projectIndustryService;
@RequestMapping(value = "getAllAvailableIndustry", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody List<Industry> getAllAvailableIndustry() {
return projectIndustryService.getAllAvailableIndustry();
}
@RequestMapping(value = "getAllAvailableIndustry", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
List<Industry> getAllAvailableIndustry() {
return projectIndustryService.getAllAvailableIndustry();
}
}
package pwc.taxtech.atms.controller;
import java.util.List;
import io.swagger.annotations.ApiOperation;
import javassist.tools.web.BadHttpRequest;
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 io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import pwc.taxtech.atms.dpo.AnalyticsModelDetail;
import pwc.taxtech.atms.dpo.FinancialStatementDetail;
import pwc.taxtech.atms.dpo.TaxReturnDetail;
import pwc.taxtech.atms.dto.*;
import pwc.taxtech.atms.dto.AddKeyValueConfigDto;
import pwc.taxtech.atms.dto.Common.RemoteValidationRetDto;
import pwc.taxtech.atms.dto.KeyValueConfigDisplayDto;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.UpdateKeyValueConfigDto;
import pwc.taxtech.atms.dto.formula.FormulaConfigDto;
import pwc.taxtech.atms.service.KeyValueConfigService;
import pwc.taxtech.atms.service.TemplateFormulaService;
import pwc.taxtech.atms.service.impl.TemplateFormulaServiceImpl;
import java.util.List;
@RestController
@RequestMapping("/api/v1/keyValueConfig")
......@@ -29,7 +37,7 @@ public class KeyValueConfigController {
private KeyValueConfigService keyValueConfigService;
@Autowired
private TemplateFormulaService templateFormulaService;
private TemplateFormulaServiceImpl templateFormulaService;
@ApiOperation(value = "get keyValueConfig")
@RequestMapping(value = "", method = RequestMethod.GET)
......@@ -111,9 +119,9 @@ public class KeyValueConfigController {
}
@RequestMapping(value="isFormulaValid", method=RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RequestMapping(value = "isFormulaValid", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
RemoteValidationRetDto isFormulaValid(@RequestParam String value){
RemoteValidationRetDto isFormulaValid(@RequestParam String value) {
OperationResultDto validateResult = templateFormulaService.validate(value);
RemoteValidationRetDto result = new RemoteValidationRetDto();
result.setIsValid(validateResult.getResult());
......
package pwc.taxtech.atms.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
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.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import pwc.taxtech.atms.dpo.ModelProfileDto;
import pwc.taxtech.atms.service.ModelConfigurationService;
import pwc.taxtech.atms.service.impl.ModelConfigurationServiceImpl;
import java.util.List;
@RestController
@RequestMapping(value = "api/v1/modelConfiguration")
public class ModelConfigurationController {
@Autowired
ModelConfigurationService modelConfigurationService;
@Autowired
ModelConfigurationServiceImpl modelConfigurationService;
@RequestMapping(value = "/model/byIndustry/{serviceTypeId}/{industryId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody List<ModelProfileDto> getModelListByIndustry(@PathVariable String industryId,
@PathVariable String serviceTypeId) {
return modelConfigurationService.getModelListByIndustry(serviceTypeId, industryId);
}
@RequestMapping(value = "/model/byIndustry/{serviceTypeId}/{industryId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
List<ModelProfileDto> getModelListByIndustry(@PathVariable String industryId,
@PathVariable String serviceTypeId) {
return modelConfigurationService.getModelListByIndustry(serviceTypeId, industryId);
}
}
......@@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RestController;
import pwc.taxtech.atms.dto.ServiceTypeDto;
import pwc.taxtech.atms.entity.ServiceType;
import pwc.taxtech.atms.service.ProjectService;
import pwc.taxtech.atms.service.ServiceTypeService;
import pwc.taxtech.atms.service.impl.ServiceTypeServiceImpl;
import java.util.List;
......@@ -21,7 +21,7 @@ public class ServiceTypeController {
@Autowired
private ProjectService projectService;
@Autowired
private ServiceTypeService serviceTypeService;
private ServiceTypeServiceImpl serviceTypeService;
@ResponseBody
@ApiOperation(value = "获取ServiceType列表")
......
......@@ -4,20 +4,25 @@ 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 org.springframework.web.bind.annotation.RequestBody;
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 pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.service.TemplateFormulaService;
import pwc.taxtech.atms.service.impl.TemplateFormulaServiceImpl;
@RestController
@RequestMapping(value = "api/v1/templateFormula")
public class TemplateFormulaController {
@Autowired
TemplateFormulaService templateFormulaService;
TemplateFormulaServiceImpl templateFormulaService;
private static final Logger logger = LoggerFactory.getLogger(TemplateFormulaController.class);
@RequestMapping(value = "validate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody OperationResultDto validate(@RequestBody(required = false) String fromula) {
public @ResponseBody
OperationResultDto validate(@RequestBody(required = false) String fromula) {
try {
return templateFormulaService.validate(fromula);
} catch (Exception e) {
......
package pwc.taxtech.atms.service;
public interface AccountService {
/**
* 匹配标准科目到企业科目(按科目编码)
* @param enterpriseAccountSetId - 账套Id
* @param stdAccountCode - 标准科目编码
* @param epAccountCode - 企业科目编码
* @param industryId - 行业Id
* @param organizationId - 机构Id
* @param bOverwrite - 是否覆盖已有对应
* @param acctLevel - 科目级别
*/
void mapStdAccountByCode (String enterpriseAccountSetId, String stdAccountCode, String epAccountCode, String industryId, String organizationId,
Boolean bOverwrite, Integer acctLevel);
}
package pwc.taxtech.atms.service;
import pwc.taxtech.atms.dto.datainit.DataInitDto;
public interface DataInitService {
DataInitDto validateAndImportInitData(String filePath);
}
package pwc.taxtech.atms.service;
import java.util.List;
import pwc.taxtech.atms.entity.Dictionary;
public interface DictionaryService {
List<Dictionary> getDictionaryByCode(String code);
}
package pwc.taxtech.atms.service;
import java.io.InputStream;
public interface FileSystemService {
/**
* 上传用户报表模板
*
* @param fileName 文件名
* @param inputStream InputStream
* @return 文件路径
* @throws Exception ex
*/
String uploadUserTemplate(String fileName, InputStream inputStream) throws Exception;
/**
* 下载用户报表模板
*
* @param filePath 文件路径
* @return InputStream
* @throws Exception ex
*/
InputStream downloadUserTemplate(String filePath) throws Exception;
}
package pwc.taxtech.atms.service;
import pwc.taxtech.atms.dpo.ModelProfileDto;
import java.util.List;
public interface ModelConfigurationService {
List<ModelProfileDto> getModelListByIndustry(String serviceTypeId, String industryId);
}
package pwc.taxtech.atms.service;
import java.util.List;
import pwc.taxtech.atms.entity.Industry;
public interface ProjectIndustryService {
List<Industry> getAllAvailableIndustry();
}
package pwc.taxtech.atms.service;
import java.util.List;
import pwc.taxtech.atms.entity.ServiceType;
public interface ServiceTypeService {
List<ServiceType> getServiceTypes();
}
package pwc.taxtech.atms.service;
import pwc.taxtech.atms.dto.OperationResultDto;
public interface TemplateFormulaService {
OperationResultDto validate(String formula);
}
......@@ -2,79 +2,85 @@ package pwc.taxtech.atms.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.CommonConstants;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.entity.AccountMapping;
import pwc.taxtech.atms.entity.AccountMappingExample;
import pwc.taxtech.atms.entity.EnterpriseAccount;
import pwc.taxtech.atms.service.AccountService;
import pwc.taxtech.atms.service.EnterpriseAccountService;
@Service
public class AccountServiceImpl extends AbstractService implements AccountService {
public class AccountServiceImpl extends AbstractService {
@Autowired
EnterpriseAccountService enterpriseAccountService;
@Autowired EnterpriseAccountService enterpriseAccountService;
/* (non-Javadoc)
* @see pwc.taxtech.atms.service.AccountService#mapStdAccountByCode(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Boolean, java.lang.Integer)
/**
* 匹配标准科目到企业科目(按科目编码)
* @param enterpriseAccountSetId - 账套Id
* @param stdAccountCode - 标准科目编码
* @param epAccountCode - 企业科目编码
* @param industryId - 行业Id
* @param organizationId - 机构Id
* @param bOverwrite - 是否覆盖已有对应
* @param acctLevel - 科目级别
*/
@Override
public void mapStdAccountByCode(String enterpriseAccountSetId, String stdAccountCode, String epAccountCode, String industryId, String organizationId,
Boolean bOverwrite, Integer acctLevel) {
Boolean bOverwrite, Integer acctLevel) {
//set default value
if(bOverwrite == null) {
if (bOverwrite == null) {
bOverwrite = true;
}
if(acctLevel == null) {
if (acctLevel == null) {
acctLevel = 0;
}
EnterpriseAccount epAccount = enterpriseAccountService.getEnterpriseAccount(epAccountCode, enterpriseAccountSetId);
if (epAccount == null) {
return;
}
//set stdAccountCode
if(stdAccountCode==null || stdAccountCode.isEmpty()) {
if (stdAccountCode == null || stdAccountCode.isEmpty()) {
stdAccountCode = CommonConstants.NullStdCode;
}
if (!bOverwrite) {
if(!isStdExists(enterpriseAccountSetId, epAccountCode, industryId, organizationId)) {
if (!isStdExists(enterpriseAccountSetId, epAccountCode, industryId, organizationId)) {
deleteAccountMapping(epAccountCode, epAccount.getEnterpriseAccountSetId(), organizationId, industryId);
updateStdAccountMapping(epAccountCode, epAccount.getEnterpriseAccountSetId(), stdAccountCode, industryId, organizationId);
}
}
else {
} else {
deleteAccountMapping(epAccountCode, epAccount.getEnterpriseAccountSetId(), organizationId, industryId);
updateStdAccountMapping(epAccountCode, epAccount.getEnterpriseAccountSetId(), stdAccountCode, industryId, organizationId);
}
}
/**
* 删除对应关系
*
* @param epAccountCode
* @param enterpriseAccountSetId
* @param organizaionId
* @param industryId
*/
private void deleteAccountMapping(String epAccountCode, String enterpriseAccountSetId, String organizaionId,
String industryId) {
String industryId) {
AccountMappingExample accountMappingExample = new AccountMappingExample();
accountMappingExample.createCriteria()
.andEnterpriseAccountCodeEqualTo(epAccountCode)
.andEnterpriseAccountSetIdEqualTo(enterpriseAccountSetId)
.andOrganizationIdEqualTo(organizaionId)
.andIndustryIdEqualTo(industryId);
.andEnterpriseAccountCodeEqualTo(epAccountCode)
.andEnterpriseAccountSetIdEqualTo(enterpriseAccountSetId)
.andOrganizationIdEqualTo(organizaionId)
.andIndustryIdEqualTo(industryId);
accountMappingMapper.deleteByExample(accountMappingExample);
}
/**
* 插入对应关系到对应关系表
*
* @param epAccountCode
* @param enterpriseAccountSetId
* @param stdAccountCode
......@@ -83,8 +89,8 @@ public class AccountServiceImpl extends AbstractService implements AccountServic
* @param organizationId
*/
private void updateStdAccountMapping(String epAccountCode, String enterpriseAccountSetId,
String stdAccountCode, String industryId, String organizationId) {
String stdAccountCode, String industryId, String organizationId) {
AccountMapping accountMapping = new AccountMapping();
accountMapping.setId(CommonUtils.getUUID());
accountMapping.setEnterpriseAccountSetId(enterpriseAccountSetId);
......@@ -96,10 +102,10 @@ public class AccountServiceImpl extends AbstractService implements AccountServic
}
private boolean isStdExists(String enterpriseAccountSetId, String enterpirseAccountCode, String industryId, String organizationId) {
Long stdAccountsCount = customAccountMapper.countStandardAccounts(enterpriseAccountSetId, enterpirseAccountCode, industryId, organizationId);
return stdAccountsCount>=1;
return stdAccountsCount >= 1;
}
}
package pwc.taxtech.atms.service.impl;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import org.nutz.lang.Files;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import pwc.taxtech.atms.common.CommonConstants;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.dto.datainit.DataCountDto;
import pwc.taxtech.atms.dto.datainit.DataInitDto;
import pwc.taxtech.atms.dto.user.UserTemp;
import pwc.taxtech.atms.entity.Area;
import pwc.taxtech.atms.entity.AreaExample;
import pwc.taxtech.atms.entity.AreaRegion;
import pwc.taxtech.atms.entity.AreaRegionExample;
import pwc.taxtech.atms.entity.BusinessUnit;
import pwc.taxtech.atms.entity.BusinessUnitExample;
import pwc.taxtech.atms.entity.Customer;
import pwc.taxtech.atms.entity.EnterpriseAccount;
import pwc.taxtech.atms.entity.Organization;
import pwc.taxtech.atms.entity.OrganizationExample;
import pwc.taxtech.atms.entity.OrganizationStructure;
import pwc.taxtech.atms.entity.OrganizationStructureExample;
import pwc.taxtech.atms.entity.Region;
import pwc.taxtech.atms.entity.RegionExample;
import pwc.taxtech.atms.entity.Role;
import pwc.taxtech.atms.entity.RoleCategory;
import pwc.taxtech.atms.entity.RoleCategoryExample;
import pwc.taxtech.atms.entity.User;
import pwc.taxtech.atms.entity.UserRole;
import pwc.taxtech.atms.service.DataInitService;
import pwc.taxtech.atms.entity.*;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
@Service
public class DataInitServiceImpl extends AbstractService implements DataInitService {
public class DataInitServiceImpl extends AbstractService {
private static final String[] sheetArray = new String[] { "机构层级", "事业部", "区域", "企业科目", "客户列表", "机构", "用户", "角色" };
private static final String[] sheetArray = new String[]{"机构层级", "事业部", "区域", "企业科目", "客户列表", "机构", "用户", "角色"};
private static final String ENABLE = "启用";
@Autowired
......@@ -52,13 +32,12 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
/*
* (non-Javadoc)
*
*
* @see
* pwc.taxtech.atms.service.DataInitService#validateImportInitData(java.lang.
* String)
*/
@SuppressWarnings("rawtypes")
@Override
public DataInitDto validateAndImportInitData(String filePath) {
logger.debug("enter DataInitServiceImpl validateImportInitData");
InputStream savedInputStream = Files.findFileAsStream(filePath);
......@@ -120,7 +99,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
} else {
dataInitDto.addErrorMsg("企业科目sheet为空");
}
/*
* 客户列表
*/
......@@ -132,7 +111,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
} else {
dataInitDto.addErrorMsg("客户列表sheet为空");
}
/*
* 机构
*/
......@@ -144,7 +123,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
} else {
dataInitDto.addErrorMsg("机构sheet为空");
}
/*
* 角色
*/
......@@ -156,7 +135,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
} else {
dataInitDto.addErrorMsg("角色sheet为空");
}
/*
* 用户
*/
......@@ -175,14 +154,14 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
/**
* 验证机构层级Excel格式, 准备数据
*
*
* @param dataInitDto
* @param headerMap
* @param dataMapCollection
*/
@SuppressWarnings("rawtypes")
private void validateOrgStructure(DataInitDto dataInitDto, Map<String, Integer> headerMap,
Collection<Map> dataMapCollection) {
Collection<Map> dataMapCollection) {
// validate header
List<String> standardHeader = Arrays.asList("层级名称", "使用状态");
......@@ -198,11 +177,11 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
// prepare data to insert
List<OrganizationStructure> importOrgStructureList = new ArrayList<>();
for (Map map : dataMapCollection) {
if(map.get("层级名称") == null || map.get("使用状态") == null) {
if (map.get("层级名称") == null || map.get("使用状态") == null) {
continue;
}
OrganizationStructure orgStructure = new OrganizationStructure();
orgStructure.setId(CommonUtils.getUUID());
orgStructure.setName(map.get("层级名称") == null ? null : map.get("层级名称").toString());
......@@ -216,14 +195,14 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
/**
* 验证区域Excel格式, 准备数据
*
*
* @param dataInitDto
* @param headerMap
* @param dataMapCollection
*/
@SuppressWarnings("rawtypes")
private void validateArea(DataInitDto dataInitDto, Map<String, Integer> headerMap,
Collection<Map> dataMapCollection) {
Collection<Map> dataMapCollection) {
// validate header
List<String> standardHeader = Arrays.asList("区域名称", "行政区域");
for (String header : standardHeader) {
......@@ -239,24 +218,24 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
List<Area> importAreaList = new ArrayList<>();
List<AreaRegion> importAreaRegionList = new ArrayList<>();
for (Map map : dataMapCollection) {
if (map.get("区域名称") == null || map.get("行政区域") == null) { // 跳过数据为空的行
continue;
}
AreaExample example = new AreaExample();
example.createCriteria().andNameEqualTo(map.get("区域名称").toString());
List<Area> dbAreaList = areaMapper.selectByExample(example);
List<Area> mappedAreaList = importAreaList.stream().filter(a -> Objects.equals(a.getName(), map.get("区域名称").toString())).collect(Collectors.toList());
//if area data not exist, then generate new one
String uuid = null;
if(!dbAreaList.isEmpty()) {
if (!dbAreaList.isEmpty()) {
uuid = dbAreaList.get(0).getId();
}
if(!mappedAreaList.isEmpty()) {
if (!mappedAreaList.isEmpty()) {
uuid = mappedAreaList.get(0).getId();
}
if(dbAreaList.isEmpty() && mappedAreaList.isEmpty()) {
if (dbAreaList.isEmpty() && mappedAreaList.isEmpty()) {
// Area data
Area area = new Area();
uuid = CommonUtils.getUUID();
......@@ -264,28 +243,28 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
area.setIsActive(true);
area.setName(map.get("区域名称").toString());
importAreaList.add(area);
}
}
// Area and Region data
List<Area> allAreas = areaMapper.selectByExample(null);
List<Area> mappedAreas = allAreas.stream().filter(a -> a.getName().contains(map.get("区域名称").toString()))
.collect(Collectors.toList());
RegionExample regionExample = new RegionExample();
regionExample.setOrderByClause("LevelType DESC");
List<Region> allRegions = regionMapper.selectByExample(regionExample);
List<String> mappedRegionIdList = allRegions.stream()
.filter(a -> a.getName().contains(map.get("行政区域").toString())).map(Region::getId)
.collect(Collectors.toList());
if(mappedRegionIdList.isEmpty()) {
if (mappedRegionIdList.isEmpty()) {
//by default, region should exist
continue;
}
for(String s : mappedRegionIdList) {
for (String s : mappedRegionIdList) {
AreaRegion areaRegion = new AreaRegion();
areaRegion.setId(CommonUtils.getUUID());
if(mappedAreas.isEmpty()) {
if (mappedAreas.isEmpty()) {
areaRegion.setAreaId(uuid);
} else {
areaRegion.setAreaId(mappedAreas.get(0).getId());
......@@ -300,14 +279,14 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
/**
* 验证企业科目Excel格式, 准备数据
*
*
* @param dataInitDto
* @param headerMap
* @param dataMapCollection
*/
@SuppressWarnings("rawtypes")
private void validateEnterpriseAccount(DataInitDto dataInitDto, Map<String, Integer> headerMap,
Collection<Map> dataMapCollection) {
Collection<Map> dataMapCollection) {
// validate header
List<String> standardHeader = Arrays.asList("企业科目代码", "企业科目名称", "借贷方向", "科目类型");
for (String header : standardHeader) {
......@@ -326,7 +305,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
|| map.get("科目类型") == null) { // 跳过数据为空的行
continue;
}
EnterpriseAccount enterpriseAccount = new EnterpriseAccount();
enterpriseAccount.setId(CommonUtils.getUUID());
enterpriseAccount.setCode(map.get("企业科目代码").toString());
......@@ -366,12 +345,12 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
}
return null;
}
private Integer getEnterpriseAccountDirection(String name) {
if(name.indexOf(CommonConstants.CreditDirectionName) > -1) {
if (name.indexOf(CommonConstants.CreditDirectionName) > -1) {
return Integer.valueOf(CommonConstants.CreditDirectionValue);
}
if(name.indexOf(CommonConstants.DebitDirectionName) > -1) {
if (name.indexOf(CommonConstants.DebitDirectionName) > -1) {
return Integer.valueOf(CommonConstants.DebitDirectionValue);
}
return null;
......@@ -379,14 +358,14 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
/**
* 验证事业部Excel格式, 准备数据
*
*
* @param dataInitDto
* @param headerMap
* @param dataMapCollection
*/
@SuppressWarnings("rawtypes")
private void validateBusinessUnit(DataInitDto dataInitDto, Map<String, Integer> headerMap,
Collection<Map> dataMapCollection) {
Collection<Map> dataMapCollection) {
// validate header
List<String> standardHeader = Arrays.asList("事业部名称", "使用状态");
......@@ -402,7 +381,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
// prepare data to insert
List<BusinessUnit> importBusinessUnitList = new ArrayList<>();
for (Map map : dataMapCollection) {
if(map.get("事业部名称") == null || map.get("使用状态") == null) {
if (map.get("事业部名称") == null || map.get("使用状态") == null) {
continue;
}
BusinessUnit businessUnit = new BusinessUnit();
......@@ -415,17 +394,17 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
}
dataInitDto.setImportBusinessUnit(importBusinessUnitList);
}
/**
* 验证客户列表Excel格式, 准备数据
*
*
* @param dataInitDto
* @param headerMap
* @param dataMapCollection
*/
@SuppressWarnings("rawtypes")
private void validateCustomer(DataInitDto dataInitDto, Map<String, Integer> headerMap,
Collection<Map> dataMapCollection) {
Collection<Map> dataMapCollection) {
// validate header
List<String> standardHeader = Arrays.asList("客户代码", "客户名称");
for (String header : standardHeader) {
......@@ -435,7 +414,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
return;
}
}
dataInitDto.setIsImportCustomerValid(true);
// prepare data to insert
......@@ -450,17 +429,17 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
}
dataInitDto.setImportCustomer(importBusinessUnitList);
}
/**
* 验证机构Excel格式, 准备数据
*
*
* @param dataInitDto
* @param headerMap
* @param dataMapCollection
*/
@SuppressWarnings("rawtypes")
private void validateOrganization(DataInitDto dataInitDto, Map<String, Integer> headerMap,
Collection<Map> dataMapCollection) {
Collection<Map> dataMapCollection) {
// validate header
List<String> standardHeader = Arrays.asList("机构名称", "机构代码", "行政地区", "纳税人识别号", "上级公司", "层级", "事业部", "地区");
for (String header : standardHeader) {
......@@ -470,19 +449,19 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
return;
}
}
dataInitDto.setIsImportOrganizationValid(true);
// prepare data to insert
List<Organization> importOrganizationList = new ArrayList<>();
for (Map map : dataMapCollection) {
if(StringUtils.isEmpty(map.get("机构名称").toString()) || StringUtils.isEmpty(map.get("机构代码").toString())
if (StringUtils.isEmpty(map.get("机构名称").toString()) || StringUtils.isEmpty(map.get("机构代码").toString())
|| StringUtils.isEmpty(map.get("行政地区").toString())
|| StringUtils.isEmpty(map.get("层级").toString()) || StringUtils.isEmpty(map.get("事业部").toString())
|| StringUtils.isEmpty(map.get("地区").toString())) {
|| StringUtils.isEmpty(map.get("层级").toString()) || StringUtils.isEmpty(map.get("事业部").toString())
|| StringUtils.isEmpty(map.get("地区").toString())) {
continue;
}
Organization organization = new Organization();
importOrganizationList.add(organization);
organization.setId(CommonUtils.getUUID());
......@@ -490,57 +469,57 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
organization.setName(map.get("机构名称").toString());
organization.setCode(map.get("机构代码").toString());
organization.setTaxPayerNumber(map.get("纳税人识别号") == null ? null : map.get("纳税人识别号").toString());
//parent id
String parentName = map.get("上级公司") == null ? null : map.get("上级公司").toString();
if(!StringUtils.isEmpty(parentName)) {
if (!StringUtils.isEmpty(parentName)) {
OrganizationExample organizationExample = new OrganizationExample();
organizationExample.createCriteria().andNameEqualTo(parentName);
List<Organization> organizationList = organizationMapper.selectByExample(organizationExample);
if(organizationList.isEmpty()) {
if (organizationList.isEmpty()) {
continue;
}
organization.setParentId(organizationList.get(0).getId());
}
//region id
RegionExample regionExample = new RegionExample();
regionExample.createCriteria().andNameEqualTo(map.get("行政地区").toString());
List<Region> regionList = regionMapper.selectByExample(regionExample);
if(regionList.isEmpty()) {
if (regionList.isEmpty()) {
continue;
}
}
organization.setRegionId(regionList.get(0).getId());
//structure id
OrganizationStructureExample organizationStructureExample = new OrganizationStructureExample();
organizationStructureExample.createCriteria().andNameEqualTo(map.get("层级").toString());
List<OrganizationStructure> organizationStructureList = organizationStructureMapper.selectByExample(organizationStructureExample);
if(organizationStructureList.isEmpty()) {
if (organizationStructureList.isEmpty()) {
continue;
}
organization.setStructureId(organizationStructureList.get(0).getId());
organization.setIndustryId(CommonConstants.INDUSTRY_Id);
//business id
BusinessUnitExample businessUnitExample = new BusinessUnitExample();
businessUnitExample.createCriteria().andNameEqualTo(map.get("事业部").toString());
List<BusinessUnit> businessUnitList = businessUnitMapper.selectByExample(businessUnitExample);
if(businessUnitList.isEmpty()) {
if (businessUnitList.isEmpty()) {
continue;
}
organization.setBusinessUnitId(businessUnitList.get(0).getId());
//area id
AreaExample areaExample = new AreaExample();
areaExample.createCriteria().andNameEqualTo(map.get("地区").toString());
List<Area> areaList = areaMapper.selectByExample(areaExample);
if(areaList.isEmpty()) {
if (areaList.isEmpty()) {
continue;
}
organization.setAreaId(areaList.get(0).getId());
organization.setIsActive(CommonConstants.ACTIVE_STATUS);
organization.setpLevel(0);
organization.setCreateTime(new Date());
......@@ -548,17 +527,17 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
}
dataInitDto.setImportOrganization(importOrganizationList);
}
/**
* 验证角色Excel格式, 准备数据
*
*
* @param dataInitDto
* @param headerMap
* @param dataMapCollection
*/
@SuppressWarnings("rawtypes")
private void validateRole(DataInitDto dataInitDto, Map<String, Integer> headerMap,
Collection<Map> dataMapCollection) {
Collection<Map> dataMapCollection) {
// validate header
List<String> standardHeader = Arrays.asList("角色名称", "角色类别", "角色描述");
for (String header : standardHeader) {
......@@ -568,18 +547,18 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
return;
}
}
dataInitDto.setIsImportRoleValid(true);
// prepare data to insert
List<Role> importRoleList = new ArrayList<>();
List<RoleCategory> importRoleCatagoryList = new ArrayList<>();
for (Map map : dataMapCollection) {
if(StringUtils.isEmpty(map.get("角色类别").toString()) || StringUtils.isEmpty(map.get("角色名称").toString())) {
if (StringUtils.isEmpty(map.get("角色类别").toString()) || StringUtils.isEmpty(map.get("角色名称").toString())) {
continue;
}
//add RoleCategory
RoleCategoryExample example = new RoleCategoryExample();
example.createCriteria().andNameEqualTo(map.get("角色类别").toString());
......@@ -587,13 +566,13 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
List<RoleCategory> mappedRoleCatagoryList = importRoleCatagoryList.stream().filter(a -> Objects.equals(a.getName(), map.get("角色类别").toString())).collect(Collectors.toList());
//not exist in database and not in list
String uuid = null;
if(!dbRoleCatagoryList.isEmpty()) {
if (!dbRoleCatagoryList.isEmpty()) {
uuid = dbRoleCatagoryList.get(0).getId();
}
if(!mappedRoleCatagoryList.isEmpty()) {
if (!mappedRoleCatagoryList.isEmpty()) {
uuid = mappedRoleCatagoryList.get(0).getId();
}
if(roleCategoryMapper.selectByExample(example).isEmpty() && mappedRoleCatagoryList.isEmpty()) {
if (roleCategoryMapper.selectByExample(example).isEmpty() && mappedRoleCatagoryList.isEmpty()) {
RoleCategory roleCatagory = new RoleCategory();
importRoleCatagoryList.add(roleCatagory);
uuid = CommonUtils.getUUID();
......@@ -602,8 +581,8 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
roleCatagory.setIsActive(CommonConstants.ACTIVE_STATUS);
roleCatagory.setCreateTime(new Date());
roleCatagory.setUpdateTime(new Date());
}
}
//add role
Role role = new Role();
importRoleList.add(role);
......@@ -615,21 +594,21 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
role.setCreateTime(new Date());
role.setUpdateTime(new Date());
}
dataInitDto.setImportRole(importRoleList);
dataInitDto.setImportRoleCategory(importRoleCatagoryList);
}
/**
* 验证用户Excel格式, 准备数据
*
*
* @param dataInitDto
* @param headerMap
* @param dataMapCollection
*/
@SuppressWarnings("rawtypes")
private void validateUser(DataInitDto dataInitDto, Map<String, Integer> headerMap,
Collection<Map> dataMapCollection) {
Collection<Map> dataMapCollection) {
// validate header
List<String> standardHeader = Arrays.asList("Admin用户", "用户名", "所属机构", "角色");
for (String header : standardHeader) {
......@@ -639,13 +618,13 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
return;
}
}
dataInitDto.setIsImportUserTempValid(true);
// prepare data to insert
List<UserTemp> importUserTempList = new ArrayList<>();
for (Map map : dataMapCollection) {
if(StringUtils.isEmpty(map.get("Admin用户").toString()) || StringUtils.isEmpty(map.get("用户名").toString())
if (StringUtils.isEmpty(map.get("Admin用户").toString()) || StringUtils.isEmpty(map.get("用户名").toString())
|| StringUtils.isEmpty(map.get("所属机构").toString()) || StringUtils.isEmpty(map.get("角色").toString())) {
continue;
}
......@@ -662,7 +641,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
/**
* 导入机构层级数据
*
*
* @param orgStructureList
* @return
*/
......@@ -670,10 +649,10 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
Long errorCount = 0L;
Long originalCount = organizationStructureMapper.countByExample(null);
List<OrganizationStructure> orgStructureList = new ArrayList<>();
//if headers are valid
if(dataInitDto.getIsImportOrgStructureValid()) {
if (dataInitDto.getIsImportOrgStructureValid()) {
/*
* 目前采用逐条插入的方法, 如今后数据量大可改用批量插入, 但需要加入数据校验
*/
......@@ -690,14 +669,14 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
Long newCount = organizationStructureMapper.countByExample(null);
DataCountDto dataCountDto = new DataCountDto(orgStructureList.size(), originalCount, newCount, errorCount, "机构层级");
dataInitDto.getValidMsgs().add(dataCountDto);
if(errorCount > 0) {
if (errorCount > 0) {
dataInitDto.getErrorMsgs().add("导入机构层级错误");
}
}
/**
* 导入事业部数据
*
*
* @param dataInitDto
* @return
*/
......@@ -707,7 +686,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
Long originalCount = businessUnitMapper.countByExample(null);
List<BusinessUnit> businessUnitList = new ArrayList<>();
if(dataInitDto.getIsImportBusinessUnitValid()) {
if (dataInitDto.getIsImportBusinessUnitValid()) {
/*
* 目前采用逐条插入的方法, 如今后数据量大可改用批量插入, 但需要加入数据校验
*/
......@@ -721,19 +700,19 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
}
}
}
Long newCount = businessUnitMapper.countByExample(null);
DataCountDto dataCountDto = new DataCountDto(businessUnitList.size(), originalCount, newCount, errorCount, "事业部");
dataInitDto.getValidMsgs().add(dataCountDto);
if(errorCount > 0) {
if (errorCount > 0) {
dataInitDto.getErrorMsgs().add("导入事业部错误");
}
}
/**
* 导入区域数据
*
*
* @param orgStructureList
* @return
*/
......@@ -746,7 +725,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
* 准备数据时需要通过非空校验
*/
List<AreaRegion> areaRegionList = new ArrayList<>();
if(dataInitDto.getIsImportAreaValid()) {
if (dataInitDto.getIsImportAreaValid()) {
// 插入Area
List<Area> areaList = dataInitDto.getImportAreaList();
areaRegionList = dataInitDto.getImportAreaRegionList();
......@@ -755,7 +734,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
//in case area exists
AreaExample areaExample = new AreaExample();
areaExample.createCriteria().andNameEqualTo(item.getName()).andIsActiveEqualTo(CommonConstants.ACTIVE_STATUS);
if(areaMapper.selectByExample(areaExample).isEmpty()) {
if (areaMapper.selectByExample(areaExample).isEmpty()) {
areaMapper.insert(item);
}
} catch (Exception e) {
......@@ -769,7 +748,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
//in case area region exists
AreaRegionExample areaRegionExample = new AreaRegionExample();
areaRegionExample.createCriteria().andAreaIdEqualTo(item.getAreaId()).andRegionIdEqualTo(item.getRegionId());
if(areaRegionMapper.selectByExample(areaRegionExample).isEmpty()) {
if (areaRegionMapper.selectByExample(areaRegionExample).isEmpty()) {
areaRegionMapper.insert(item);
}
} catch (Exception e) {
......@@ -783,23 +762,23 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
DataCountDto dataCountDto = new DataCountDto(areaRegionList.size(), originalCount, newCount, errorCount, "区域");
dataInitDto.getValidMsgs().add(dataCountDto);
if(errorCount > 0) {
if (errorCount > 0) {
dataInitDto.getErrorMsgs().add("导入区域错误");
}
}
/**
* 导入企业科目数据
*
*
* @param orgStructureList
* @return
*/
private void importEnterpriseAccount(DataInitDto dataInitDto) {
Long errorCount = 0L;
Long originalCount = enterpriseAccountMapper.countByExample(null);
List<EnterpriseAccount> enterpriseAccountList = new ArrayList<>();
if(dataInitDto.getIsImportEnterpriseAccountValid()) {
if (dataInitDto.getIsImportEnterpriseAccountValid()) {
/*
* 准备数据时需要通过非空校验
*/
......@@ -814,19 +793,19 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
}
}
}
Long newCount = enterpriseAccountMapper.countByExample(null);
DataCountDto dataCountDto = new DataCountDto(enterpriseAccountList.size(), originalCount, newCount, errorCount, "企业科目");
dataInitDto.getValidMsgs().add(dataCountDto);
if(errorCount > 0) {
if (errorCount > 0) {
dataInitDto.getErrorMsgs().add("导入企业科目错误");
}
}
/**
* 导入客户列表数据
*
*
* @param dataInitDto
* @return
*/
......@@ -835,7 +814,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
Long originalCount = customerMapper.countByExample(null);
List<Customer> customerList = new ArrayList<>();
if(dataInitDto.getIsImportCustomerValid()) {
if (dataInitDto.getIsImportCustomerValid()) {
/*
* 准备数据时需要通过非空校验
*/
......@@ -850,28 +829,28 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
}
}
}
Long newCount = customerMapper.countByExample(null);
DataCountDto dataCountDto = new DataCountDto(customerList.size(), originalCount, newCount, errorCount, "客户列表");
dataInitDto.getValidMsgs().add(dataCountDto);
if(errorCount > 0) {
if (errorCount > 0) {
dataInitDto.getErrorMsgs().add("导入客户列表错误");
}
}
/**
* 导入机构数据
*
*
* @param organizationList
* @return
*/
private void importOrganization(DataInitDto dataInitDto) {
Long errorCount = 0L;
Long originalCount = organizationMapper.countByExample(null);
List<Organization> organizationList = new ArrayList<>();
if(dataInitDto.getIsImportOrganizationValid()) {
if (dataInitDto.getIsImportOrganizationValid()) {
RegionExample regionExample = new RegionExample();
regionExample.setOrderByClause("LevelType DESC");
/*
......@@ -888,18 +867,19 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
}
}
}
Long newCount = organizationMapper.countByExample(null);
DataCountDto dataCountDto = new DataCountDto(organizationList.size(), originalCount, newCount, errorCount, "机构");
dataInitDto.getValidMsgs().add(dataCountDto);
if(errorCount > 0) {
if (errorCount > 0) {
dataInitDto.getErrorMsgs().add("导入机构列表错误");
}
}
/**
* 导入角色数据
*
* @param dataInitDto
* @return
*/
......@@ -909,7 +889,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
Long originalCount = roleMapper.countByExample(null);
List<Role> roleList = new ArrayList<>();
if(dataInitDto.getIsImportRoleValid()) {
if (dataInitDto.getIsImportRoleValid()) {
/*
* 准备数据时需要通过非空校验
*/
......@@ -923,10 +903,10 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
logger.debug("Error inserting 角色类别: " + e.getMessage());
}
}
List<RoleCategory> queryList = roleCategoryMapper.selectByExample(null);
//插入角色
for(Role role : roleList) {
for (Role role : roleList) {
//用Id替换掉名字
String oldId = role.getRoleCategoryId();
RoleCategory newObject = queryList.stream().filter(a -> Objects.equals(a.getName(), oldId)).findFirst().orElse(null);
......@@ -942,13 +922,14 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
Long newCount = roleMapper.countByExample(null);
DataCountDto dataCountDto = new DataCountDto(roleList.size(), originalCount, newCount, errorCount, "角色");
dataInitDto.getValidMsgs().add(dataCountDto);
if(errorCount > 0) {
if (errorCount > 0) {
dataInitDto.getErrorMsgs().add("导入角色列表错误");
}
}
/**
* 导入用户数据
*
* @param dataInitDto
* @return
*/
......@@ -957,7 +938,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
Long originalCount = userMapper.countByExample(null);
List<UserTemp> userTempList = new ArrayList<>();
if(dataInitDto.getIsImportUserTempValid()) {
if (dataInitDto.getIsImportUserTempValid()) {
/*
* 准备数据时需要通过非空校验
*/
......@@ -965,12 +946,12 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
userTempList = dataInitDto.getImportUserTemp();
List<Organization> orgList = organizationMapper.selectByExample(null);
List<Role> roleList = roleMapper.selectByExample(null);
for (UserTemp item : userTempList) {
try {
User user = new User();
Organization orgObject = orgList.stream().filter(a -> Objects.equals(a.getName(), item.getOrganizationName())).findFirst().orElse(null);
if(orgObject != null) {
if (orgObject != null) {
String userId = CommonUtils.getUUID();
user.setId(userId);
user.setUserName(item.getUserName());
......@@ -984,9 +965,9 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
user.setOrganizationId(orgObject.getId());
userMapper.insert(user);
String[] roleNames = item.getRoleName().split("\\,|\\,");
for(String roleName : roleNames) {
for (String roleName : roleNames) {
Role roleObject = roleList.stream().filter(a -> Objects.equals(a.getName(), roleName)).findFirst().orElse(null);
if(roleObject != null) {
if (roleObject != null) {
UserRole userRole = new UserRole();
userRole.setId(CommonUtils.getUUID());
userRole.setUserId(userId);
......@@ -1002,12 +983,12 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
}
}
}
Long newCount = userMapper.countByExample(null);
DataCountDto dataCountDto = new DataCountDto(userTempList.size(), originalCount, newCount, errorCount, "用户");
dataInitDto.getValidMsgs().add(dataCountDto);
if(errorCount > 0) {
if (errorCount > 0) {
dataInitDto.getErrorMsgs().add("导入用户列表错误");
}
}
......
package pwc.taxtech.atms.service.impl;
import java.util.List;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.entity.Dictionary;
import pwc.taxtech.atms.entity.DictionaryExample;
import pwc.taxtech.atms.service.DictionaryService;
import java.util.List;
@Service
public class DictionaryServiceImpl extends AbstractService implements DictionaryService {
public class DictionaryServiceImpl extends AbstractService {
@Override
public List<Dictionary> getDictionaryByCode(String code) {
DictionaryExample example = new DictionaryExample();
example.createCriteria().andCodeEqualTo(code).andIsActiveEqualTo(true);
......
......@@ -11,14 +11,24 @@ import org.nutz.lang.Files;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import pwc.taxtech.atms.common.*;
import pwc.taxtech.atms.common.CommonConstants;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.OperateLogType;
import pwc.taxtech.atms.common.OperationAction;
import pwc.taxtech.atms.common.OperationModule;
import pwc.taxtech.atms.common.message.EnterpriseAccountMessage;
import pwc.taxtech.atms.common.message.EnterpriseAccountSetOrgMsg;
import pwc.taxtech.atms.common.message.LogMessage;
import pwc.taxtech.atms.constant.EnterpriseAccountConstant;
import pwc.taxtech.atms.constant.IndustryConstant;
import pwc.taxtech.atms.constant.enums.AccountRuleEnum;
import pwc.taxtech.atms.dao.*;
import pwc.taxtech.atms.dao.AccountMappingDao;
import pwc.taxtech.atms.dao.AccountMappingManualDao;
import pwc.taxtech.atms.dao.AccountMappingManualMapper;
import pwc.taxtech.atms.dao.EnterpriseAccountDao;
import pwc.taxtech.atms.dao.EnterpriseAccountSetOrgDao;
import pwc.taxtech.atms.dao.OrganizationMapper;
import pwc.taxtech.atms.dao.StandardAccountDao;
import pwc.taxtech.atms.dpo.EnterpriseAccountDto;
import pwc.taxtech.atms.dto.OperationLogDto;
import pwc.taxtech.atms.dto.OperationResultDto;
......@@ -31,7 +41,6 @@ import pwc.taxtech.atms.dto.epaccount.EnterpriseAccountAndValidateInfo;
import pwc.taxtech.atms.dto.epaccount.EnterpriseAccountSetDto;
import pwc.taxtech.atms.dto.stdaccount.StandardAccountDto;
import pwc.taxtech.atms.entity.*;
import pwc.taxtech.atms.service.AccountService;
import pwc.taxtech.atms.service.EnterpriseAccountService;
import pwc.taxtech.atms.service.EnterpriseAccountSetService;
......@@ -43,7 +52,7 @@ import java.util.stream.Collectors;
public class EnterpriseAccountServiceImpl extends AbstractService implements EnterpriseAccountService {
@Autowired
private AccountService accountService;
private AccountServiceImpl accountService;
@Autowired
private EnterpriseAccountSetService enterpriseAccountSetService;
@Autowired
......@@ -64,8 +73,8 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
private OrganizationMapper organizationMapper;
private Map<String, List<String>> mapParentAccountResult;
/* (non-Javadoc)
* @see pwc.taxtech.atms.service.EnterpriseAccountService#getEnterpriseAccount(java.lang.String, java.lang.String)
*/
......@@ -73,14 +82,14 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
public EnterpriseAccount getEnterpriseAccount(String enterpriseAccountCode, String enterpriseAccountSetId) {
EnterpriseAccountExample example = new EnterpriseAccountExample();
example.createCriteria().andCodeEqualTo(enterpriseAccountCode).andEnterpriseAccountSetIdEqualTo(enterpriseAccountSetId);
List<EnterpriseAccount> epAccounts = enterpriseAccountMapper.selectByExample(example);
return CollectionUtils.isEmpty(epAccounts)?null:epAccounts.get(0);
return CollectionUtils.isEmpty(epAccounts) ? null : epAccounts.get(0);
}
/*
* (non-Javadoc)
*
*
* @see pwc.taxtech.atms.service.EnterpriseAccountService#
* getListByEnterpriseAccountSetId(java.lang.String)
*/
......@@ -89,99 +98,101 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
EnterpriseAccountExample enterpriseAccountExample = new EnterpriseAccountExample();
enterpriseAccountExample.createCriteria()
.andRuleTypeEqualTo(2)
.andEnterpriseAccountSetIdEqualTo(enterpriseAccountSetId);
.andRuleTypeEqualTo(2)
.andEnterpriseAccountSetIdEqualTo(enterpriseAccountSetId);
enterpriseAccountExample.setOrderByClause("PARENT_CODE ASC, IS_ACTIVE DESC, CODE ASC");
List<EnterpriseAccount> epAccounts = enterpriseAccountMapper.selectByExample(enterpriseAccountExample);
//no enterprise account
if(epAccounts==null || epAccounts.isEmpty()) {
if (epAccounts == null || epAccounts.isEmpty()) {
return new EnterpriseAccountAndValidateInfo();
}
//get all standard accounts
StandardAccountExample standardAccountExample = new StandardAccountExample();
List<StandardAccount> stdAccounts = standardAccountMapper.selectByExample(standardAccountExample);
//set stdName
List<EnterpriseAccountDto> epAccountDtoList = new ArrayList<>();
for(EnterpriseAccount epAccount: epAccounts) {
for (EnterpriseAccount epAccount : epAccounts) {
EnterpriseAccountDto epAccountDto = new EnterpriseAccountDto();
CommonUtils.copyProperties(epAccount, epAccountDto);
epAccountDto.setParentName("");
epAccountDto.setParentFullName("");
epAccountDto.setStdName("");
stdAccounts.stream().filter(stdAccount -> stdAccount.getCode().equals(epAccount.getStdCode())).findFirst()
.ifPresent(stdAccount -> {epAccountDto.setStdName(stdAccount.getName());});
.ifPresent(stdAccount -> {
epAccountDto.setStdName(stdAccount.getName());
});
epAccountDtoList.add(epAccountDto);
}
//wrap epAccounts and generate retEpAccountDtoList
List<EnterpriseAccountDto> retEpAccountDtoList = new ArrayList<>();
List<EnterpriseAccountDto> topEpAccountDtoList
= epAccountDtoList.stream().filter(epAccountDto -> epAccountDto.getParentCode() == null)
List<EnterpriseAccountDto> topEpAccountDtoList
= epAccountDtoList.stream().filter(epAccountDto -> epAccountDto.getParentCode() == null)
.collect(Collectors.toList());
for(EnterpriseAccountDto epAccountDto: topEpAccountDtoList) {
for (EnterpriseAccountDto epAccountDto : topEpAccountDtoList) {
epAccountDto.setTreeLevel(0);
retEpAccountDtoList.add(epAccountDto);
retEpAccountDtoList.addAll(getWrapList(epAccountDto, epAccountDtoList));
}
//lost epAccounts list
for(EnterpriseAccountDto epAccountDto: epAccountDtoList) {
if( !retEpAccountDtoList.contains(epAccountDto)) {
for (EnterpriseAccountDto epAccountDto : epAccountDtoList) {
if (!retEpAccountDtoList.contains(epAccountDto)) {
retEpAccountDtoList.add(epAccountDto);
}
}
//validate enterprise account list
List<ValidateInfoDto> validateInfoList = validateEnterpriseAccountList(retEpAccountDtoList);
EnterpriseAccountAndValidateInfo enterpriseAccountAndValidateInfo = new EnterpriseAccountAndValidateInfo();
enterpriseAccountAndValidateInfo.setEnterpriseAccountList(retEpAccountDtoList);
enterpriseAccountAndValidateInfo.setValidateInfoList(validateInfoList);
return enterpriseAccountAndValidateInfo;
}
/* (non-Javadoc)
* @see pwc.taxtech.atms.service.EnterpriseAccountService#getEnterpriseAccount(java.lang.String)
*/
@Override
public EnterpriseAccountDto getEnterpriseAccount(String enterpriseAccountId) {
EnterpriseAccount enterpriseAccount = enterpriseAccountMapper.selectByPrimaryKey(enterpriseAccountId);
//get all enterprise accounts
EnterpriseAccountExample enterpriseAccountExample = new EnterpriseAccountExample();
enterpriseAccountExample.createCriteria()
.andIsActiveEqualTo(CommonConstants.ACTIVE_STATUS)
.andRuleTypeEqualTo(2)
.andEnterpriseAccountSetIdEqualTo(enterpriseAccount.getEnterpriseAccountSetId());
.andIsActiveEqualTo(CommonConstants.ACTIVE_STATUS)
.andRuleTypeEqualTo(2)
.andEnterpriseAccountSetIdEqualTo(enterpriseAccount.getEnterpriseAccountSetId());
List<EnterpriseAccount> epAccounts = enterpriseAccountMapper.selectByExample(enterpriseAccountExample);
//get all standard accounts
StandardAccountExample standardAccountExample = new StandardAccountExample();
List<StandardAccount> stdAccounts = standardAccountMapper.selectByExample(standardAccountExample);
EnterpriseAccountDto enterpriseAccountDto = new EnterpriseAccountDto();
CommonUtils.copyProperties(enterpriseAccount, enterpriseAccountDto);
epAccounts.stream().filter(epAccount -> enterpriseAccount.getParentCode()!=null && enterpriseAccount.getParentCode().equals(epAccount.getCode())).findFirst()
.ifPresent(epAccount -> {
enterpriseAccountDto.setParentName(epAccount.getName());
enterpriseAccountDto.setParentFullName(epAccount.getFullName());
epAccounts.stream().filter(epAccount -> enterpriseAccount.getParentCode() != null && enterpriseAccount.getParentCode().equals(epAccount.getCode())).findFirst()
.ifPresent(epAccount -> {
enterpriseAccountDto.setParentName(epAccount.getName());
enterpriseAccountDto.setParentFullName(epAccount.getFullName());
});
stdAccounts.stream().filter(stdAccount -> stdAccount.getCode().equals(enterpriseAccount.getStdCode())).findFirst()
.ifPresent(stdAccount -> {
enterpriseAccountDto.setStdName(stdAccount.getName());
.ifPresent(stdAccount -> {
enterpriseAccountDto.setStdName(stdAccount.getName());
});
enterpriseAccountDto.setSubStdAccounts(new ArrayList<>());
enterpriseAccountDto.setIndustryId("");
return enterpriseAccountDto;
}
/* (non-Javadoc)
* @see pwc.taxtech.atms.service.EnterpriseAccountService#addEnterpriseAccount(pwc.taxtech.atms.service.dto.EnterpriseAccountDto)
*/
......@@ -189,15 +200,15 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
@Transactional
public OperationResultDto<List<EnterpriseAccountDto>> addEnterpriseAccount(EnterpriseAccountDto enterpriseAccountDto) {
if(enterpriseAccountDto == null) {
if (enterpriseAccountDto == null) {
return new OperationResultDto<>(false);
}
EnterpriseAccount entityToAdd = new EnterpriseAccount();
CommonUtils.copyProperties(enterpriseAccountDto, entityToAdd);
//check duplication ep account
List<EnterpriseAccountDto> sameEpAccounts = getSameEnterpriseAccountList(enterpriseAccountDto);
if(sameEpAccounts!=null && !sameEpAccounts.isEmpty()) {
if (sameEpAccounts != null && !sameEpAccounts.isEmpty()) {
return new OperationResultDto<>(false, EnterpriseAccountMessage.EnterpriceAccountRepeat, sameEpAccounts);
}
//set parent account no leaf
......@@ -210,22 +221,22 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
entityToAdd.setCreatorId(authUserHelper.getCurrentUserId());
entityToAdd.setUpdatorId(authUserHelper.getCurrentUserId());
enterpriseAccountMapper.insert(entityToAdd);
//获取与之关联的机构
EnterpriseAccountSetOrgExample example = new EnterpriseAccountSetOrgExample();
example.createCriteria().andEnterpriseAccountSetIdEqualTo(enterpriseAccountDto.getEnterpriseAccountSetId());
List<EnterpriseAccountSetOrg> accountSetOrgList = enterpriseAccountSetOrgMapper.selectByExampleWithAssociation(example);
//构造数据结构,调用更新父级科目对应方法
List<String> epAccountCodeList = new ArrayList<>();
epAccountCodeList.add(entityToAdd.getCode());
this.mapParentAccountResult = new HashMap<>();
for(EnterpriseAccountSetOrg accountSetOrg : accountSetOrgList) {
for (EnterpriseAccountSetOrg accountSetOrg : accountSetOrgList) {
String industryId = organizationMapper.selectByPrimaryKey(accountSetOrg.getOrganizationId()).getIndustryId();
mapAccountUpdateParent(epAccountCodeList, accountSetOrg.getEnterpriseAccountSetId(), getConvertedIndustryId(industryId), accountSetOrg.getOrganizationId(), true);
}
//get enterprise set name
EnterpriseAccountSet enterpriseAccountSet = enterpriseAccountSetMapper.selectByPrimaryKey(enterpriseAccountDto.getEnterpriseAccountSetId());
//add operational log
......@@ -240,7 +251,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
updateLogParams.setComment("");
updateLogParams.setOperationAction(OperationAction.New.value());
operationLogService.addOrDeleteDataAddLog(updateLogParams);
return new OperationResultDto<>(true);
}
......@@ -251,49 +262,49 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
@Transactional
public OperationResultDto<List<EnterpriseAccountDto>> updateEnterpriseAccount(EnterpriseAccountDto enterpriseAccountDto) {
if(enterpriseAccountDto == null) {
if (enterpriseAccountDto == null) {
return new OperationResultDto<>(false);
}
EnterpriseAccount entityToUpdate = enterpriseAccountMapper.selectByPrimaryKey(enterpriseAccountDto.getId());
if(entityToUpdate == null) {
if (entityToUpdate == null) {
return new OperationResultDto<>(false);
}
//check duplication ep account
List<EnterpriseAccountDto> sameEpAccounts = getSameEnterpriseAccountList(enterpriseAccountDto);
if(sameEpAccounts!=null && !sameEpAccounts.isEmpty()) {
if (sameEpAccounts != null && !sameEpAccounts.isEmpty()) {
return new OperationResultDto<>(false, EnterpriseAccountMessage.EnterpriceAccountRepeat, sameEpAccounts);
}
//copy entityToUpdate
EnterpriseAccount entityCopy = new EnterpriseAccount();
CommonUtils.copyProperties(entityToUpdate, entityCopy);
if(entityCopy.getParentCode()!=null && !entityCopy.getParentCode().equals(enterpriseAccountDto.getParentCode())) {
if (entityCopy.getParentCode() != null && !entityCopy.getParentCode().equals(enterpriseAccountDto.getParentCode())) {
// reset the isleaf
setParentIsNotLeaf(enterpriseAccountDto.getParentCode(), enterpriseAccountDto.getEnterpriseAccountSetId());
setParentLeaf(entityCopy.getParentCode(), enterpriseAccountDto.getEnterpriseAccountSetId(), enterpriseAccountDto.getId());
}
//查询所有原本对应子科目
//如修改的为父科目, 需要级联修改其所有子科目的父科目代码以及名字
EnterpriseAccountExample enterpriseAccountexample = new EnterpriseAccountExample();
enterpriseAccountexample.createCriteria()
.andParentCodeEqualTo(entityCopy.getCode())
.andEnterpriseAccountSetIdEqualTo(enterpriseAccountDto.getEnterpriseAccountSetId());
.andParentCodeEqualTo(entityCopy.getCode())
.andEnterpriseAccountSetIdEqualTo(enterpriseAccountDto.getEnterpriseAccountSetId());
List<EnterpriseAccount> childrenAccountList = enterpriseAccountMapper.selectByExample(enterpriseAccountexample);
if(childrenAccountList!=null && !childrenAccountList.isEmpty()) {
if(!entityCopy.getCode().equals(enterpriseAccountDto.getCode()) || !entityCopy.getName().equals(enterpriseAccountDto.getName())) {
for(EnterpriseAccount childrenAccount: childrenAccountList) {
if (childrenAccountList != null && !childrenAccountList.isEmpty()) {
if (!entityCopy.getCode().equals(enterpriseAccountDto.getCode()) || !entityCopy.getName().equals(enterpriseAccountDto.getName())) {
for (EnterpriseAccount childrenAccount : childrenAccountList) {
childrenAccount.setParentCode(enterpriseAccountDto.getCode());
childrenAccount.setFullName(enterpriseAccountDto.getFullName() + EnterpriseAccountConstant.FullNameSeparator + childrenAccount.getName());
enterpriseAccountMapper.updateByPrimaryKey(childrenAccount);
}
}
}
entityToUpdate.setCode(enterpriseAccountDto.getCode());
entityToUpdate.setName(enterpriseAccountDto.getName());
entityToUpdate.setFullName(enterpriseAccountDto.getFullName());
......@@ -302,39 +313,39 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
entityToUpdate.setAcctProp(enterpriseAccountDto.getAcctProp());
entityToUpdate.setStdCode(enterpriseAccountDto.getStdCode());
enterpriseAccountMapper.updateByPrimaryKey(entityToUpdate);
//获取与之关联的机构
EnterpriseAccountSetOrgExample example = new EnterpriseAccountSetOrgExample();
example.createCriteria().andEnterpriseAccountSetIdEqualTo(enterpriseAccountDto.getEnterpriseAccountSetId());
List<EnterpriseAccountSetOrg> accountSetOrgList = enterpriseAccountSetOrgMapper.selectByExampleWithAssociation(example);
//构造数据结构,调用更新父级科目对应方法
List<String> epAccountCodeList = new ArrayList<>();
epAccountCodeList.add(entityToUpdate.getCode());
this.mapParentAccountResult = new HashMap<>();
for(EnterpriseAccountSetOrg accountSetOrg : accountSetOrgList) {
if(entityToUpdate.getParentCode()!=null && entityToUpdate.getParentCode().equals(entityCopy.getParentCode())) {
for (EnterpriseAccountSetOrg accountSetOrg : accountSetOrgList) {
if (entityToUpdate.getParentCode() != null && entityToUpdate.getParentCode().equals(entityCopy.getParentCode())) {
/* @See below C#代码 EnterpriseAccountService.cs Line 238-240
* string updateSql = "UPDATE AccountMapping SET StandardAccountCode='00' WHERE EnterpriseAccountCode={0} AND EnterpriseAccountSetId={1} AND OrganizationId={2} AND IndustryId={3}";
_dbContext.Database.ExecuteSqlCommand(updateSql, entity.id, item.EnterpriseAccountSetId, item.OrganizationId, GetConvertedIndustryId(item.IndustryId));
* EnterpriseAccountCode 参数应该设错了
*/
//需要清除旧的对应关系
AccountMapping accountMapping = new AccountMapping();
accountMapping.setStandardAccountCode("00");
AccountMappingExample accountMappingExample = new AccountMappingExample();
accountMappingExample.createCriteria()
.andEnterpriseAccountCodeEqualTo(entityCopy.getParentCode())
.andEnterpriseAccountSetIdEqualTo(accountSetOrg.getEnterpriseAccountSetId())
.andOrganizationIdEqualTo(accountSetOrg.getOrganizationId())
.andIndustryIdEqualTo(getConvertedIndustryId(accountSetOrg.getOrganization().getIndustryId()));
.andEnterpriseAccountCodeEqualTo(entityCopy.getParentCode())
.andEnterpriseAccountSetIdEqualTo(accountSetOrg.getEnterpriseAccountSetId())
.andOrganizationIdEqualTo(accountSetOrg.getOrganizationId())
.andIndustryIdEqualTo(getConvertedIndustryId(accountSetOrg.getOrganization().getIndustryId()));
accountMappingMapper.updateByExampleSelective(accountMapping, accountMappingExample);
}
mapAccountUpdateParent(epAccountCodeList, accountSetOrg.getEnterpriseAccountSetId(),
getConvertedIndustryId(accountSetOrg.getOrganization().getIndustryId()), accountSetOrg.getOrganizationId(), true);
getConvertedIndustryId(accountSetOrg.getOrganization().getIndustryId()), accountSetOrg.getOrganizationId(), true);
}
//get enterprise set name
EnterpriseAccountSet enterpriseAccountSet = enterpriseAccountSetMapper.selectByPrimaryKey(enterpriseAccountDto.getEnterpriseAccountSetId());
......@@ -350,126 +361,122 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
updateLogParams.setComment("");
updateLogParams.setOperationAction(OperationAction.UpdateEnterpriseAccount.value());
operationLogService.addOrDeleteDataAddLog(updateLogParams);
enableEnterpriseAccountSet(enterpriseAccountDto.getEnterpriseAccountSetId());
return new OperationResultDto<>(true);
}
/* (non-Javadoc)
* @see pwc.taxtech.atms.service.EnterpriseAccountService#mapAccountUpdateParent(java.util.List, java.lang.String, java.lang.String, java.lang.String, java.lang.Boolean)
*/
@Override
public void mapAccountUpdateParent(List<String> enterpriseAccountCodeList, String enterpriseAccountSetId,
String industryId, String orgId, Boolean isToUpdateEvenExists) {
String industryId, String orgId, Boolean isToUpdateEvenExists) {
for (String epAccountCode : enterpriseAccountCodeList) {
/* 数据准备 start */
String mappedStdCode = "";
//第一步:通过企业科目Code获取企业科目对象
EnterpriseAccountExample enterpriseAccountExample = new EnterpriseAccountExample();
enterpriseAccountExample.createCriteria()
.andEnterpriseAccountSetIdEqualTo(enterpriseAccountSetId)
.andCodeEqualTo(epAccountCode);
.andEnterpriseAccountSetIdEqualTo(enterpriseAccountSetId)
.andCodeEqualTo(epAccountCode);
List<EnterpriseAccount> epAccounts = enterpriseAccountMapper.selectByExample(enterpriseAccountExample);
if(CollectionUtils.isEmpty(epAccounts)) {
if (CollectionUtils.isEmpty(epAccounts)) {
continue;
}
EnterpriseAccount epAccount = epAccounts.get(0);
//如果当前对应的本身就是第一级,不需要再考虑
if(epAccount.getParentCode() == null || epAccount.getParentCode().isEmpty()) {
if (epAccount.getParentCode() == null || epAccount.getParentCode().isEmpty()) {
continue;
}
//第二步: 通过上一步获取到的企业科目对象的ParentCode获取企业企业科目对象
enterpriseAccountExample = new EnterpriseAccountExample();
enterpriseAccountExample.createCriteria()
.andEnterpriseAccountSetIdEqualTo(enterpriseAccountSetId)
.andCodeEqualTo(epAccount.getParentCode());
.andEnterpriseAccountSetIdEqualTo(enterpriseAccountSetId)
.andCodeEqualTo(epAccount.getParentCode());
List<EnterpriseAccount> parentEpAccounts = enterpriseAccountMapper.selectByExample(enterpriseAccountExample);
if(CollectionUtils.isEmpty(parentEpAccounts)) {
if (CollectionUtils.isEmpty(parentEpAccounts)) {
return; //C# return
}
EnterpriseAccount parentEpAccount = parentEpAccounts.get(0);
//第三步: 通过Parent企业科目对象获取该ParentCode下面的所有子企业科目
List<EnterpriseAccount> childrenEpAccountList = getMappingResultByParentCode(parentEpAccount.getCode(), enterpriseAccountSetId, industryId, orgId);
//第四步: 判断第三步获取到企业科目中,标准科目为空的个数
if(CollectionUtils.isEmpty(childrenEpAccountList)) {
if (CollectionUtils.isEmpty(childrenEpAccountList)) {
continue;
}
long emptyStdCodeCount = childrenEpAccountList.stream().filter(sa -> sa.getStdCode()==null || sa.getStdCode().isEmpty()).count();
long emptyStdCodeCount = childrenEpAccountList.stream().filter(sa -> sa.getStdCode() == null || sa.getStdCode().isEmpty()).count();
//第五部: 将第三步获取到的所有企业科目取出其中的StdCode并去重
List<String> uniqueStdCodeList = childrenEpAccountList.stream()
.filter(sa -> sa.getStdCode()!=null && !sa.getStdCode().isEmpty())
.filter(sa -> sa.getStdCode() != null && !sa.getStdCode().isEmpty())
.map(sa -> sa.getStdCode()).collect(Collectors.toList());
/* 数据准备 end */
/* 业务处理 start */
//等于0说明子科目全部都有对应上
if(emptyStdCodeCount == 0) {
if (emptyStdCodeCount == 0) {
long countOfDistinctStdCode = uniqueStdCodeList.size();
//等于1说明对应上的标准科目都是同一个
if(countOfDistinctStdCode == 1) {
if (countOfDistinctStdCode == 1) {
//2. 手动对应,子科目完全对应的时候并且都对应到同一个标准科目,那么父级也要对应到该标准科目
mappedStdCode = uniqueStdCodeList.get(0);
}
//说明虽然完全对应上了,但是对应上的标准科目代码不唯一
else {
//3. 手动对应,子科目完全对应的时候但是没有对应到同一个标准科目
StandardAccountExample standardAccountExample = new StandardAccountExample();
standardAccountExample.createCriteria()
.andCodeIn(uniqueStdCodeList).andIndustryIdEqualTo(industryId);
.andCodeIn(uniqueStdCodeList).andIndustryIdEqualTo(industryId);
List<StandardAccount> standardAccountList = standardAccountMapper.selectByExample(standardAccountExample);
if(CollectionUtils.isEmpty(standardAccountList)) {
if (CollectionUtils.isEmpty(standardAccountList)) {
continue;
}
List<String> distinctStdParentCodeList = standardAccountList.stream()
.map(sa -> sa.getParentCode()).distinct().collect(Collectors.toList());
long uniqueStdParentCodeCount = distinctStdParentCodeList.size();
//等于1说明对应上的都属于同一个父级标准科目
if(uniqueStdParentCodeCount == 1
&& distinctStdParentCodeList.get(0)!=null && !distinctStdParentCodeList.get(0).isEmpty()
if (uniqueStdParentCodeCount == 1
&& distinctStdParentCodeList.get(0) != null && !distinctStdParentCodeList.get(0).isEmpty()
&& !uniqueStdCodeList.contains("0000")) {
//子科目完全对应的时候但是没有对应到同一个标准科目但是属于同一个父科目下,那么该企业科目的父级也要对应到该标准科目的父级
mappedStdCode = standardAccountList.get(0).getParentCode();
}
else {
} else {
//子科目完全对应的时候但是没有对应到同一个标准科目又不属于同一个父科目下,那么该企业科目的父级显示为横线 -
mappedStdCode = CommonConstants.EmptyStdCode;
}
}
}
else {
} else {
//4. 手动对应,子科目没有全对应的时候,那么父级科目显示为未对应
mappedStdCode = null;
}
/* 更新UI准备 start */
StandardAccount stdAccount = new StandardAccount();
if(mappedStdCode == CommonConstants.EmptyStdCode) {
if (mappedStdCode == CommonConstants.EmptyStdCode) {
stdAccount.setCode(CommonConstants.EmptyStdCode);
stdAccount.setName("");
}
else if(mappedStdCode == null) {
} else if (mappedStdCode == null) {
stdAccount.setCode(null);
stdAccount.setName("");
}
else {
} else {
StandardAccountExample standardAccountExample = new StandardAccountExample();
standardAccountExample.createCriteria()
.andCodeEqualTo(mappedStdCode)
.andIndustryIdEqualTo(industryId);
.andCodeEqualTo(mappedStdCode)
.andIndustryIdEqualTo(industryId);
List<StandardAccount> stdAccountList = standardAccountMapper.selectByExample(standardAccountExample);
if (CollectionUtils.isEmpty(stdAccountList)) {
continue;
......@@ -477,13 +484,13 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
stdAccount = stdAccountList.get(0);
}
addMapParentAccountResult(parentEpAccount.getCode(), Arrays.asList(stdAccount.getCode(), stdAccount.getName()));
//更新该企业科目的标准科目为mappedStdCode
accountService.mapStdAccountByCode(enterpriseAccountSetId, stdAccount.getCode(), epAccountCode, industryId, orgId, isToUpdateEvenExists, 0);
/* 更新UI准备 end */
/* 业务处理 end */
/* 如果还存在上一级的情况,所以递归处理 start */
mapAccountUpdateParent(Arrays.asList(parentEpAccount.getCode()), enterpriseAccountSetId, industryId, orgId, isToUpdateEvenExists);
/* 如果还存在上一级的情况,所以递归处理 end */
......@@ -497,22 +504,22 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
@Override
@Transactional
public OperationResultDto addEnterpriseAccountSetAndImportData(String enterpriseAccountSetName,
String enterpriseAccountSetCode, List<EnterpriseAccountDto> importData) {
String enterpriseAccountSetCode, List<EnterpriseAccountDto> importData) {
EnterpriseAccountSetDto enterpriseAccountSetDto = new EnterpriseAccountSetDto();
enterpriseAccountSetDto.setName(enterpriseAccountSetName);
enterpriseAccountSetDto.setCode(enterpriseAccountSetCode);
//validate name is duplicated
OperationResultDto<?> nameValidate = enterpriseAccountSetService.enterpriseAccountSetNameValidate(enterpriseAccountSetDto);
if(!nameValidate.getResult()) {
if (!nameValidate.getResult()) {
return nameValidate;
}
//validate code is duplicated
OperationResultDto<?> codeValidate = enterpriseAccountSetService.enterpriseAccountSetCodeValidate(enterpriseAccountSetDto);
if(!codeValidate.getResult()) {
if (!codeValidate.getResult()) {
return codeValidate;
}
//save enterprise account set
EnterpriseAccountSet enterpriseAccountSet = new EnterpriseAccountSet();
CommonUtils.copyProperties(enterpriseAccountSetDto, enterpriseAccountSet);
......@@ -522,7 +529,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
enterpriseAccountSet.setUpdateTime(new Date());
enterpriseAccountSet.setCreatorId(authUserHelper.getCurrentUserId());
enterpriseAccountSetMapper.insert(enterpriseAccountSet);
//create operationlog for creating enterprise account set
UpdateLogParams updateLogParams = new UpdateLogParams();
updateLogParams.setOperationUser(authUserHelper.getCurrentAuditor().get());
......@@ -535,17 +542,17 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
updateLogParams.setOperationAction(OperationAction.AddEnterpriseAccountSet.value());
updateLogParams.setOperationObject(enterpriseAccountSet.getName());
operationLogService.addOrDeleteDataAddLog(updateLogParams);
//nothing to import
if(importData == null && CollectionUtils.isEmpty(importData)) {
if (importData == null && CollectionUtils.isEmpty(importData)) {
return OperationResultDto.success();
}
importDataProcess(importData, enterpriseAccountSet.getId(), true);
return OperationResultDto.success();
}
/* (non-Javadoc)
* @see pwc.taxtech.atms.service.EnterpriseAccountService#repeatImportEnterpriseAccountSet(pwc.taxtech.atms.dto.epaccount.EnterpriseAccountSetDto, java.util.List)
......@@ -554,71 +561,72 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
@Override
@Transactional
public OperationResultDto repeatImportEnterpriseAccountSet(EnterpriseAccountSetDto enterpriseAccountSetDto,
List<EnterpriseAccountDto> importData) {
List<EnterpriseAccountDto> importData) {
return importDataProcess(importData, enterpriseAccountSetDto.getId(), enterpriseAccountSetDto.getIsImportAppend());
}
/* (non-Javadoc)
* @see pwc.taxtech.atms.service.EnterpriseAccountService#clearRepeatEnterpriseAccountList(pwc.taxtech.atms.dto.epaccount.EnterpriseAccountSetDto)
*/
@SuppressWarnings("rawtypes")
@Override
public OperationResultDto clearRepeatEnterpriseAccountList(EnterpriseAccountSetDto enterpriseAccountSetDto) {
EnterpriseAccountExample enterpriseAccountExample = new EnterpriseAccountExample();
enterpriseAccountExample.createCriteria()
.andEnterpriseAccountSetIdEqualTo(enterpriseAccountSetDto.getId());
.andEnterpriseAccountSetIdEqualTo(enterpriseAccountSetDto.getId());
List<EnterpriseAccount> epAccountList = enterpriseAccountMapper.selectByExample(enterpriseAccountExample);
if(enterpriseAccountSetDto.getRepeatCodeList() == null && enterpriseAccountSetDto.getRepeatCodeList().isEmpty()) {
if (enterpriseAccountSetDto.getRepeatCodeList() == null && enterpriseAccountSetDto.getRepeatCodeList().isEmpty()) {
return OperationResultDto.success();
}
//删除重复项 留1个
for(String repeatCode: enterpriseAccountSetDto.getRepeatCodeList()) {
for (String repeatCode : enterpriseAccountSetDto.getRepeatCodeList()) {
List<EnterpriseAccount> repeatedEpAccountList = epAccountList.stream()
.filter(sa -> sa.getCode().equals(repeatCode)).collect(Collectors.toList());
for(int i=0; i<repeatedEpAccountList.size()-1; i++) {
for (int i = 0; i < repeatedEpAccountList.size() - 1; i++) {
enterpriseAccountMapper.deleteByPrimaryKey(repeatedEpAccountList.get(i).getId());
}
}
enableEnterpriseAccountSet(enterpriseAccountSetDto.getId());
return OperationResultDto.success();
}
/**
* Generate by-level wrapped enterprise Account list
*
* @param currentEpAccountDto
* @param epAccountDtoList
* @return List<EnterpriseAccountDto>
*/
private List<EnterpriseAccountDto> getWrapList(EnterpriseAccountDto currentEpAccountDto, List<EnterpriseAccountDto> epAccountDtoList) {
List<EnterpriseAccountDto> result = new ArrayList<>();
List<EnterpriseAccountDto> subList = epAccountDtoList.stream()
.filter(epAccountDto -> currentEpAccountDto.getCode().equals(epAccountDto.getParentCode()))
.collect(Collectors.toList());
if(subList!=null && !subList.isEmpty()) {
for(EnterpriseAccountDto sub: subList) {
sub.setTreeLevel(currentEpAccountDto.getTreeLevel()+1);
if (subList != null && !subList.isEmpty()) {
for (EnterpriseAccountDto sub : subList) {
sub.setTreeLevel(currentEpAccountDto.getTreeLevel() + 1);
sub.setParentName(currentEpAccountDto.getName());
sub.setParentFullName(currentEpAccountDto.getFullName());
result.add(sub);
List<EnterpriseAccountDto> tempList = getWrapList(sub, epAccountDtoList);
if(tempList!=null && !tempList.isEmpty()) {
if (tempList != null && !tempList.isEmpty()) {
result.addAll(tempList);
}
}
}
return result;
}
/* (non-Javadoc)
* @see pwc.taxtech.atms.service.EnterpriseAccountService#getAccountMappingOrg(java.lang.String)
*/
......@@ -627,9 +635,9 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
AccountMappingExample accountMappingExample = new AccountMappingExample();
accountMappingExample.createCriteria()
.andOrganizationIdEqualTo(organizationId);
.andOrganizationIdEqualTo(organizationId);
List<AccountMapping> accountMappingList = accountMappingMapper.selectByExample(accountMappingExample);
List<AccountMappingDto> accountMappingDtoList = new ArrayList<>();
accountMappingList.stream().forEach(accountMapping -> {
AccountMappingDto accountMappingDto = new AccountMappingDto();
......@@ -1142,8 +1150,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
}
}
public void addManualMappingRecord(AccountMappingManual manualMapping)
{
public void addManualMappingRecord(AccountMappingManual manualMapping) {
mappingManualDao.delMapping(manualMapping.getFullName(), manualMapping.getEnterpriseAccountSetId(),
manualMapping.getOrganizationId(), manualMapping.getIndustryId());
mappingManualMapper.insertSelective(manualMapping);
......@@ -1217,7 +1224,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
}
private void applyPriorityKeywords(List<EnterpriseAccountDto> allEpAccountDtoList, List<AccountMappingManual> allManualList,
String accountSetId, String orgId, String industryId){
String accountSetId, String orgId, String industryId) {
List<AccountMappingManualDto> resultList;
//1 账套机构行业都一样 (本身优先级别最高)
List<AccountMappingManual> tmpManualList = allManualList.stream().filter(x -> StringUtils.equals(x.getEnterpriseAccountSetId(), accountSetId)
......@@ -1260,9 +1267,9 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
resultList = getManualMappingResult(resultList, wrapPriority(tmpManualList, 8));
List<AccountMapping> mappingList = Lists.newArrayList();
resultList.stream().forEach(x->{
allEpAccountDtoList.stream().filter(EnterpriseAccountDto::getIsLeaf).forEach(y->{
if (StringUtils.equals(x.getFullName(),y.getFullName())){
resultList.stream().forEach(x -> {
allEpAccountDtoList.stream().filter(EnterpriseAccountDto::getIsLeaf).forEach(y -> {
if (StringUtils.equals(x.getFullName(), y.getFullName())) {
AccountMapping tmp = new AccountMapping();
tmp.setId(CommonUtils.getUUID());
tmp.setEnterpriseAccountCode(y.getCode());
......@@ -1342,6 +1349,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
/**
* Validates the enterprise account list.
*
* @param epAccountList
* @return The validate list
*/
......@@ -1353,177 +1361,184 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
validateInfoDtolist.add(this.getAcctPropNullValidate(epAccountList));
validateInfoDtolist.add(this.getAcctPropValidate(epAccountList));
validateInfoDtolist.add(this.getNoParentValidate(epAccountList));
return validateInfoDtolist.stream()
.filter(validateInfo -> validateInfo.getInValidateCodeList()!=null && !validateInfo.getInValidateCodeList().isEmpty())
.filter(validateInfo -> validateInfo.getInValidateCodeList() != null && !validateInfo.getInValidateCodeList().isEmpty())
.collect(Collectors.toList());
}
/**
* Validates if there is any duplication account code in the list
*
* @param list
* @return ValidateInfoDto
*/
private ValidateInfoDto getRepeatValidate(List<EnterpriseAccountDto> epAccountList) {
ValidateInfoDto validateInfoDto = new ValidateInfoDto();
validateInfoDto.setType(EnterpriseAccountMessage.EnterpriceAccountRepeat);
List<String> distinctCodeList = epAccountList.stream()
.map(epAccount -> epAccount.getCode()).distinct().collect(Collectors.toList());
for(String code: distinctCodeList) {
for (String code : distinctCodeList) {
List<EnterpriseAccountDto> accountsWithSameCode = epAccountList.stream()
.filter(epAccount -> code.equals(epAccount.getCode())).collect(Collectors.toList());
if(accountsWithSameCode!=null && accountsWithSameCode.size()>1) {
if (accountsWithSameCode != null && accountsWithSameCode.size() > 1) {
validateInfoDto.addInValidateCode(code);
}
}
return validateInfoDto;
}
/**
* Validates if there is any account with wrong direction value
* Validates if there is any account with wrong direction value
*
* @param epAccountList
* @return ValidateInfoDto
*/
private ValidateInfoDto getDirectionValidate(List<EnterpriseAccountDto> epAccountList) {
ValidateInfoDto validateInfoDto = new ValidateInfoDto();
validateInfoDto.setType(EnterpriseAccountMessage.DirectionFormatError);
List<String> inValidateCodeList = epAccountList.stream()
.filter(epAccount ->
!CommonConstants.CreditDirectionValue.equals(epAccount.getDirection()) && !CommonConstants.DebitDirectionValue.equals(epAccount.getDirection()))
.filter(epAccount ->
!CommonConstants.CreditDirectionValue.equals(epAccount.getDirection()) && !CommonConstants.DebitDirectionValue.equals(epAccount.getDirection()))
.map(epAccount -> epAccount.getCode())
.distinct().collect(Collectors.toList());
validateInfoDto.setInValidateCodeList(inValidateCodeList);
return validateInfoDto;
}
/**
* Validates if there is any account with wrong accprop value
*
* @param epAccountList
* @return ValidateInfoDto
*/
private ValidateInfoDto getAcctPropValidate(List<EnterpriseAccountDto> epAccountList) {
ValidateInfoDto validateInfoDto = new ValidateInfoDto();
validateInfoDto.setType(EnterpriseAccountMessage.AcctPropFormatError);
List<String> inValidateCodeList = epAccountList.stream()
.filter(epAccount ->
epAccount.getAcctProp()!=null && (epAccount.getAcctProp() > EnterpriseAccountConstant.MaxAcctPropValue || (epAccount.getAcctProp() < EnterpriseAccountConstant.MinAcctPropValue && epAccount.getAcctProp() != EnterpriseAccountConstant.SpecialAcctPropValue)))
.filter(epAccount ->
epAccount.getAcctProp() != null && (epAccount.getAcctProp() > EnterpriseAccountConstant.MaxAcctPropValue || (epAccount.getAcctProp() < EnterpriseAccountConstant.MinAcctPropValue && epAccount.getAcctProp() != EnterpriseAccountConstant.SpecialAcctPropValue)))
.map(epAccount -> epAccount.getCode())
.distinct().collect(Collectors.toList());
validateInfoDto.setInValidateCodeList(inValidateCodeList);
return validateInfoDto;
}
/**
* Validates if there is any account with null accprop value
*
* @param epAccountList
* @return ValidateInfoDto
*/
private ValidateInfoDto getAcctPropNullValidate(List<EnterpriseAccountDto> epAccountList) {
ValidateInfoDto validateInfoDto = new ValidateInfoDto();
validateInfoDto.setType(EnterpriseAccountMessage.AcctPropNullError);
List<String> inValidateCodeList = epAccountList.stream()
.filter(epAccount ->
epAccount.getAcctProp()==null)
.filter(epAccount ->
epAccount.getAcctProp() == null)
.map(epAccount -> epAccount.getCode())
.distinct().collect(Collectors.toList());
validateInfoDto.setInValidateCodeList(inValidateCodeList);
return validateInfoDto;
}
/**
* Validates if there is any account with empty name
*
* @param epAccountList
* @return ValidateInfoDto
*/
private ValidateInfoDto getEmptyNameValidate(List<EnterpriseAccountDto> epAccountList) {
ValidateInfoDto validateInfoDto = new ValidateInfoDto();
validateInfoDto.setType(EnterpriseAccountMessage.EnterpriseAccountNameEmpty);
List<String> inValidateCodeList = epAccountList.stream()
.filter(epAccount -> epAccount.getName() == null || epAccount.getName().equals(""))
.map(epAccount -> epAccount.getCode())
.distinct().collect(Collectors.toList());
validateInfoDto.setInValidateCodeList(inValidateCodeList);
return validateInfoDto;
}
/**
* Validates if there is any account with empty name
*
* @param epAccountList
* @return ValidateInfoDto
*/
private ValidateInfoDto getNoParentValidate(List<EnterpriseAccountDto> epAccountList) {
ValidateInfoDto validateInfoDto = new ValidateInfoDto();
validateInfoDto.setType(EnterpriseAccountMessage.NoParentCode);
List<EnterpriseAccountDto> accountsWithParent = epAccountList.stream().filter(epAccount -> epAccount.getParentCode()!=null && !epAccount.getParentCode().equals(""))
List<EnterpriseAccountDto> accountsWithParent = epAccountList.stream().filter(epAccount -> epAccount.getParentCode() != null && !epAccount.getParentCode().equals(""))
.collect(Collectors.toList());
for (EnterpriseAccountDto accountWithParent: accountsWithParent) {
for (EnterpriseAccountDto accountWithParent : accountsWithParent) {
boolean parentExist = epAccountList.stream()
.anyMatch(epAccount -> epAccount.getCode().equals(accountWithParent.getParentCode()));
if(!parentExist) {
.anyMatch(epAccount -> epAccount.getCode().equals(accountWithParent.getParentCode()));
if (!parentExist) {
validateInfoDto.addInValidateCode(accountWithParent.getCode());
}
}
return validateInfoDto;
}
/**
* Gets the same enterprise account list.
*
* @param enterpriseAccountDto
* @return
*/
private List<EnterpriseAccountDto> getSameEnterpriseAccountList(EnterpriseAccountDto enterpriseAccountDto){
private List<EnterpriseAccountDto> getSameEnterpriseAccountList(EnterpriseAccountDto enterpriseAccountDto) {
if (enterpriseAccountDto == null) {
return null;
}
EnterpriseAccountExample enterpriseAccountExample = new EnterpriseAccountExample();
EnterpriseAccountExample.Criteria criteria = enterpriseAccountExample.createCriteria();
if(enterpriseAccountDto.getId()!=null && !enterpriseAccountDto.getId().isEmpty()) {
if (enterpriseAccountDto.getId() != null && !enterpriseAccountDto.getId().isEmpty()) {
criteria.andIdNotEqualTo(enterpriseAccountDto.getId());
}
criteria.andEnterpriseAccountSetIdEqualTo(enterpriseAccountDto.getEnterpriseAccountSetId())
.andCodeEqualTo(enterpriseAccountDto.getCode())
.andIsActiveEqualTo(CommonConstants.ACTIVE_STATUS);
.andCodeEqualTo(enterpriseAccountDto.getCode())
.andIsActiveEqualTo(CommonConstants.ACTIVE_STATUS);
List<EnterpriseAccount> epAccountsWithSameCode = enterpriseAccountMapper.selectByExample(enterpriseAccountExample);
//没有重复项
if(epAccountsWithSameCode == null || epAccountsWithSameCode.isEmpty()) {
if (epAccountsWithSameCode == null || epAccountsWithSameCode.isEmpty()) {
return null;
}
//有重复项
List<EnterpriseAccountDto> sameEnterpriseAccountDtoList = new ArrayList<>();
for(EnterpriseAccount enterpriseAccount : epAccountsWithSameCode) {
for (EnterpriseAccount enterpriseAccount : epAccountsWithSameCode) {
enterpriseAccountExample = new EnterpriseAccountExample();
criteria = enterpriseAccountExample.createCriteria();
if(enterpriseAccount.getParentCode()!=null && !enterpriseAccount.getParentCode().isEmpty()) {
if (enterpriseAccount.getParentCode() != null && !enterpriseAccount.getParentCode().isEmpty()) {
criteria.andCodeEqualTo(enterpriseAccount.getParentCode());
}
criteria.andRuleTypeEqualTo(2)
.andIsActiveEqualTo(CommonConstants.ACTIVE_STATUS);
criteria.andRuleTypeEqualTo(2)
.andIsActiveEqualTo(CommonConstants.ACTIVE_STATUS);
List<EnterpriseAccount> epAccountsParent = enterpriseAccountMapper.selectByExample(enterpriseAccountExample);
if(epAccountsParent!=null&&!epAccountsParent.isEmpty()) {
if (epAccountsParent != null && !epAccountsParent.isEmpty()) {
epAccountsParent.stream().forEach(epAccountParent -> {
EnterpriseAccountDto epAccountDto = new EnterpriseAccountDto();
CommonUtils.copyProperties(enterpriseAccount, epAccountDto);
......@@ -1532,8 +1547,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
epAccountDto.setSubStdAccounts(new ArrayList<>());
sameEnterpriseAccountDtoList.add(epAccountDto);
});
}
else {
} else {
EnterpriseAccountDto epAccountDto = new EnterpriseAccountDto();
CommonUtils.copyProperties(enterpriseAccount, epAccountDto);
epAccountDto.setParentName("");
......@@ -1544,27 +1558,28 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
}
return sameEnterpriseAccountDtoList;
}
/**
* Sets the parent is not leaf.
* @param parentCode - The parent code
*
* @param parentCode - The parent code
* @param enterpriseAccountSetId - The enterprise account set identifier
*/
private void setParentIsNotLeaf(String parentCode, String enterpriseAccountSetId) {
// no parent, do nothing
if(parentCode == null || parentCode.isEmpty()) {
if (parentCode == null || parentCode.isEmpty()) {
return;
}
EnterpriseAccountExample example = new EnterpriseAccountExample();
example.createCriteria().andCodeEqualTo(parentCode).andEnterpriseAccountSetIdEqualTo(enterpriseAccountSetId);
List<EnterpriseAccount> parentNodes = enterpriseAccountMapper.selectByExample(example);
if(parentNodes==null || parentNodes.isEmpty()) {
if (parentNodes == null || parentNodes.isEmpty()) {
return;
}
EnterpriseAccount parentNode = parentNodes.get(0);
if(parentNode!=null && parentNode.getIsLeaf().equals(CommonConstants.IsLeaf)) {
if (parentNode != null && parentNode.getIsLeaf().equals(CommonConstants.IsLeaf)) {
//save enterpriseAccount
EnterpriseAccount parentNodeOriginal = new EnterpriseAccount();
CommonUtils.copyProperties(parentNode, parentNodeOriginal);
......@@ -1584,40 +1599,41 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
operationLogService.updateDataAddLog(updateLogParams);
}
}
/**
* Sets the parent leaf.
* @param parentCode - The parentcode
*
* @param parentCode - The parentcode
* @param enterpriseAccountSetId
* @param currentEpAccountId - Current enterprise account id
* @param currentEpAccountId - Current enterprise account id
*/
private void setParentLeaf(String parentCode, String enterpriseAccountSetId, String currentEpAccountId) {
// no parent, do nothing
if(parentCode == null || parentCode.isEmpty()) {
if (parentCode == null || parentCode.isEmpty()) {
return;
}
EnterpriseAccount parentNodeEntity = getEnterpriseAccount(parentCode, enterpriseAccountSetId);
if(parentNodeEntity == null) {
if (parentNodeEntity == null) {
return;
}
//copy parentNodeEntity
EnterpriseAccount parentNodeOriginal = new EnterpriseAccount();
CommonUtils.copyProperties(parentNodeEntity, parentNodeOriginal);
//get other children nodes of this parent
EnterpriseAccountExample example = new EnterpriseAccountExample();
example.createCriteria()
.andParentCodeEqualTo(parentNodeEntity.getCode())
.andIdNotEqualTo(currentEpAccountId)
.andEnterpriseAccountSetIdEqualTo(enterpriseAccountSetId);
.andParentCodeEqualTo(parentNodeEntity.getCode())
.andIdNotEqualTo(currentEpAccountId)
.andEnterpriseAccountSetIdEqualTo(enterpriseAccountSetId);
List<EnterpriseAccount> childrenAccountsOfparentNode = enterpriseAccountMapper.selectByExample(example);
if(CollectionUtils.isEmpty(childrenAccountsOfparentNode)) {
if (CollectionUtils.isEmpty(childrenAccountsOfparentNode)) {
// no sub node list, set is the leaf node
parentNodeEntity.setIsLeaf(CommonConstants.IsLeaf);
enterpriseAccountMapper.updateByPrimaryKey(parentNodeEntity);
//operation log
UpdateLogParams updateLogParams = new UpdateLogParams();
updateLogParams.setOriginalState(parentNodeOriginal);
......@@ -1632,67 +1648,62 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
operationLogService.updateDataAddLog(updateLogParams);
}
}
/**
* 通过Parent企业科目对象获取该ParentCode下面的所有子企业科目
* @param parentCode - Parent企业科目代码
*
* @param parentCode - Parent企业科目代码
* @param accountSetId - 企业账套Id
* @param industryId - 行业Id
* @param orgId - 机构Id
* @param industryId - 行业Id
* @param orgId - 机构Id
* @return
*/
private List<EnterpriseAccount> getMappingResultByParentCode(String parentCode, String accountSetId, String industryId, String orgId) {
return customAccountMapper.getMappingResult(accountSetId, industryId, orgId, parentCode);
}
private void addMapParentAccountResult(String key, List<String> value)
{
if (!mapParentAccountResult.containsKey(key))
{
private void addMapParentAccountResult(String key, List<String> value) {
if (!mapParentAccountResult.containsKey(key)) {
this.mapParentAccountResult.put(key, value);
}
}
private String getConvertedIndustryId(String industryId)
{
if (industryId != null && industryId.equals(IndustryConstant.RealEstateId))
{
private String getConvertedIndustryId(String industryId) {
if (industryId != null && industryId.equals(IndustryConstant.RealEstateId)) {
return industryId;
}
return IndustryConstant.GeneralIndustryId;
}
private String getEnterpriseAccountInfo(EnterpriseAccount enterpriseAccount)
{
private String getEnterpriseAccountInfo(EnterpriseAccount enterpriseAccount) {
String str = "";
if (enterpriseAccount.getAcctProp()!=null && enterpriseAccount.getAcctProp() < EnterpriseAccountConstant.acctPropLogList.size()) {
if (enterpriseAccount.getAcctProp() != null && enterpriseAccount.getAcctProp() < EnterpriseAccountConstant.acctPropLogList.size()) {
if (enterpriseAccount.getAcctProp() <= -1) {
str = EnterpriseAccountConstant.acctPropLogList.get(0);
}
else {
} else {
str = EnterpriseAccountConstant.acctPropLogList.get(enterpriseAccount.getAcctProp());
}
}
return enterpriseAccount.getCode() + " "
+ enterpriseAccount.getName() + " " + str + " "
+ EnterpriseAccountConstant.directionLogMap.get(enterpriseAccount.getDirection());
return enterpriseAccount.getCode() + " "
+ enterpriseAccount.getName() + " " + str + " "
+ EnterpriseAccountConstant.directionLogMap.get(enterpriseAccount.getDirection());
}
private void enableEnterpriseAccountSet(String enterpriseAccountSetId) {
EnterpriseAccountSet enterpriseAccountSet = enterpriseAccountSetMapper.selectByPrimaryKey(enterpriseAccountSetId);
if(enterpriseAccountSet.getIsActive()) {
if (enterpriseAccountSet.getIsActive()) {
return;
}
EnterpriseAccountExample example = new EnterpriseAccountExample();
example.createCriteria().andEnterpriseAccountSetIdEqualTo(enterpriseAccountSetId);
List<EnterpriseAccount> enterpriseAccountList = enterpriseAccountMapper.selectByExample(example);
if (CollectionUtils.isEmpty(enterpriseAccountList)) {
return;
}
List<EnterpriseAccountDto> enterpriseAccountDtoList = new ArrayList<>();
enterpriseAccountList.stream().forEach(sa -> {
EnterpriseAccountDto enterpriseAccountDto = new EnterpriseAccountDto();
......@@ -1701,161 +1712,159 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
});
List<ValidateInfoDto> validateInfoDtoList = validateEnterpriseAccountList(enterpriseAccountDtoList);
boolean anyValidationErrorExist = validateInfoDtoList.stream().filter(sa -> !CollectionUtils.isEmpty(sa.getInValidateCodeList())).findAny().isPresent();
if(!anyValidationErrorExist) {
if(!enterpriseAccountSet.getIsActive()) {
if (!anyValidationErrorExist) {
if (!enterpriseAccountSet.getIsActive()) {
enterpriseAccountSet.setIsActive(CommonConstants.ACTIVE_STATUS);
enterpriseAccountSetMapper.updateByPrimaryKey(enterpriseAccountSet);
}
}
}
/* (non-Javadoc)
* @see pwc.taxtech.atms.service.EnterpriseAccountService#validateImportEnterpriseAccount(java.io.InputStream, java.lang.String)
*/
@Override
public OperationResultDto<List<EnterpriseAccountDto>> validateImportEnterpriseAccount(String filePath) {
//validate header
InputStream savedInputStream = Files.findFileAsStream(filePath);
Map<String, Integer> headerMap = fileService.readExcelHeaderAndClose(savedInputStream);
List<String> standardHeader = Arrays.asList(
EnterpriseAccountConstant.Code,
EnterpriseAccountConstant.Name,
EnterpriseAccountConstant.ParentCode,
EnterpriseAccountConstant.Direction,
EnterpriseAccountConstant.Code,
EnterpriseAccountConstant.Name,
EnterpriseAccountConstant.ParentCode,
EnterpriseAccountConstant.Direction,
EnterpriseAccountConstant.AcctProp);
boolean hasParentCode = true;
for(String header: standardHeader) {
for (String header : standardHeader) {
Integer index = headerMap.get(header);
if(index == null) {
if(header.equals(EnterpriseAccountConstant.ParentCode)) {
if (index == null) {
if (header.equals(EnterpriseAccountConstant.ParentCode)) {
hasParentCode = false;
continue;
}
return new OperationResultDto<>(false, EnterpriseAccountMessage.EnterpriceAccountImportDataFormatError);
}
}
//read excel data
savedInputStream = Files.findFileAsStream(filePath);
Collection<Map> mapCollection = fileService.readExcelAndClose(savedInputStream);
//nothing to import
if(mapCollection==null || CollectionUtils.isEmpty(mapCollection)) {
if (mapCollection == null || CollectionUtils.isEmpty(mapCollection)) {
return new OperationResultDto<>(true);
}
//validate data
List<EnterpriseAccountDto> importData = new ArrayList<>();
for (Map map: mapCollection) {
for (Map map : mapCollection) {
EnterpriseAccountDto enterpriseAccountDto = new EnterpriseAccountDto();
//direction
String direction = map.get(EnterpriseAccountConstant.Direction)==null ? null: map.get(EnterpriseAccountConstant.Direction).toString();
String direction = map.get(EnterpriseAccountConstant.Direction) == null ? null : map.get(EnterpriseAccountConstant.Direction).toString();
if (direction == null || direction.trim().isEmpty()) {
direction = CommonConstants.DebitDirection;
}
try {
enterpriseAccountDto.setDirection(Integer.valueOf(direction));
}
catch (NumberFormatException e) {
} catch (NumberFormatException e) {
return new OperationResultDto<>(false, EnterpriseAccountMessage.DirectionFormatError);
}
//accprop
String acctProp = map.get(EnterpriseAccountConstant.AcctProp)==null ? null:map.get(EnterpriseAccountConstant.AcctProp).toString();
if(acctProp == null || acctProp.trim().isEmpty()) {
String acctProp = map.get(EnterpriseAccountConstant.AcctProp) == null ? null : map.get(EnterpriseAccountConstant.AcctProp).toString();
if (acctProp == null || acctProp.trim().isEmpty()) {
acctProp = "-1";
}
try {
enterpriseAccountDto.setAcctProp(Integer.valueOf(acctProp));
}
catch (NumberFormatException e) {
} catch (NumberFormatException e) {
return new OperationResultDto<>(false, EnterpriseAccountMessage.AcctPropFormatError);
}
//code
String code = map.get(EnterpriseAccountConstant.Code)==null ? null:map.get(EnterpriseAccountConstant.Code).toString();
if(code == null || code.trim().isEmpty()) {
String code = map.get(EnterpriseAccountConstant.Code) == null ? null : map.get(EnterpriseAccountConstant.Code).toString();
if (code == null || code.trim().isEmpty()) {
return new OperationResultDto<>(false, EnterpriseAccountMessage.CodeEmpty);
}
if(code.length()>EnterpriseAccountConstant.CodeMaxLength) {
if (code.length() > EnterpriseAccountConstant.CodeMaxLength) {
return new OperationResultDto<>(false, EnterpriseAccountMessage.CodeMaxLength);
}
enterpriseAccountDto.setCode(code);
//name
String name = map.get(EnterpriseAccountConstant.Name)==null ? null:map.get(EnterpriseAccountConstant.Name).toString();
if(name==null || name.trim().isEmpty()) {
String name = map.get(EnterpriseAccountConstant.Name) == null ? null : map.get(EnterpriseAccountConstant.Name).toString();
if (name == null || name.trim().isEmpty()) {
name = "";
}
if(name.length()>EnterpriseAccountConstant.NameMaxLength) {
if (name.length() > EnterpriseAccountConstant.NameMaxLength) {
return new OperationResultDto<>(false, EnterpriseAccountMessage.NameMaxLength);
}
enterpriseAccountDto.setName(name);
//parentCode
String parentCode = "";
if(hasParentCode) {
parentCode = map.get(EnterpriseAccountConstant.ParentCode)==null ? null:map.get(EnterpriseAccountConstant.ParentCode).toString();
if (hasParentCode) {
parentCode = map.get(EnterpriseAccountConstant.ParentCode) == null ? null : map.get(EnterpriseAccountConstant.ParentCode).toString();
}
if(enterpriseAccountDto.getCode().equals(parentCode)) {
if (enterpriseAccountDto.getCode().equals(parentCode)) {
parentCode = "";
}
enterpriseAccountDto.setParentCode(parentCode);
importData.add(enterpriseAccountDto);
}
OperationResultDto<List<EnterpriseAccountDto>> result = new OperationResultDto<>(true);
OperationResultDto<List<EnterpriseAccountDto>> result = new OperationResultDto<>(true);
result.setData(importData);
return result;
}
private OperationResultDto<?> importDataProcess(List<EnterpriseAccountDto> importData, String enterpriseAccountSetId, boolean isImportAppend) {
//nothing to import
if(CollectionUtils.isEmpty(importData) && isImportAppend) {
if (CollectionUtils.isEmpty(importData) && isImportAppend) {
return OperationResultDto.success();
}
// transfrom data
List<EnterpriseAccount> importEntityList = transform(importData, enterpriseAccountSetId);
//disable EnterpriseAccountSet
EnterpriseAccountSet enterpriseAccountSet = enterpriseAccountSetMapper.selectByPrimaryKey(enterpriseAccountSetId);
if(enterpriseAccountSet.getIsActive()) {
if (enterpriseAccountSet.getIsActive()) {
enterpriseAccountSet.setIsActive(CommonConstants.DEACTIVE_STATUS);
enterpriseAccountSetMapper.updateByPrimaryKey(enterpriseAccountSet);
}
//import
//如覆盖导入先批量删除
if(!isImportAppend) {
if (!isImportAppend) {
EnterpriseAccountExample example = new EnterpriseAccountExample();
example.createCriteria().andEnterpriseAccountSetIdEqualTo(enterpriseAccountSetId);
enterpriseAccountMapper.deleteByExample(example);
}
//导入
for(EnterpriseAccount importEntity: importEntityList) {
for (EnterpriseAccount importEntity : importEntityList) {
enterpriseAccountMapper.insertSelective(importEntity);
}
//enable EnterpriseAccountSet
enableEnterpriseAccountSet(enterpriseAccountSetId);
return OperationResultDto.success();
}
/**
* @param importData
* @param enterpriseAccountSetId
* @return
*/
private List<EnterpriseAccount> transform(List<EnterpriseAccountDto> importData, String enterpriseAccountSetId) {
if(CollectionUtils.isEmpty(importData)) {
if (CollectionUtils.isEmpty(importData)) {
return new ArrayList<>();
}
importData.stream().forEach(account -> {
......@@ -1868,33 +1877,31 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
account.setCreatorId(userId);
account.setUpdatorId(userId);
});
//set parent code,
List<String> validateCodeList = importData.stream().map(sa -> sa.getCode()).collect(Collectors.toList());
for (EnterpriseAccountDto enterpriseAccountDto: importData) {
if(enterpriseAccountDto.getParentCode()==null || enterpriseAccountDto.getParentCode().isEmpty()) {
for (EnterpriseAccountDto enterpriseAccountDto : importData) {
if (enterpriseAccountDto.getParentCode() == null || enterpriseAccountDto.getParentCode().isEmpty()) {
enterpriseAccountDto.setParentCode(getMatchParentCode(enterpriseAccountDto.getCode(), validateCodeList));
}
}
//set acct level,is leaf
List<String> parentCodeList = importData.stream().filter(sa -> sa.getParentCode()!=null && !sa.getParentCode().isEmpty())
List<String> parentCodeList = importData.stream().filter(sa -> sa.getParentCode() != null && !sa.getParentCode().isEmpty())
.map(sa -> sa.getParentCode()).collect(Collectors.toList());
for (EnterpriseAccountDto enterpriseAccountDto: importData) {
for (EnterpriseAccountDto enterpriseAccountDto : importData) {
setAcctLevel(enterpriseAccountDto, importData);
if(CollectionUtils.isEmpty(parentCodeList)) {
if (CollectionUtils.isEmpty(parentCodeList)) {
enterpriseAccountDto.setIsLeaf(true);
}
else {
if(parentCodeList.contains(enterpriseAccountDto.getCode())) {
} else {
if (parentCodeList.contains(enterpriseAccountDto.getCode())) {
enterpriseAccountDto.setIsLeaf(false);
}
else {
} else {
enterpriseAccountDto.setIsLeaf(true);
}
}
}
//populate entity list
List<EnterpriseAccount> enterpriseAccountList = new ArrayList<>();
importData.stream().forEach(enterpriseAccountDto -> {
......@@ -1903,37 +1910,39 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
enterpriseAccount.setRuleType(2);
enterpriseAccountList.add(enterpriseAccount);
});
return enterpriseAccountList;
}
/**
* Get parent Code from existing validated code list
*
* @param code
* @param validateCodeList
* @return parent code
*/
private String getMatchParentCode(String code, List<String> validateCodeList) {
for(int i = code.length()-1; i>=0; i--) {
for (int i = code.length() - 1; i >= 0; i--) {
String temp = code.substring(0, i);
List<String> matchList = validateCodeList.stream().filter(vCode -> vCode.equals(temp)).collect(Collectors.toList());
if(matchList!=null && matchList.size()==1) {
if (matchList != null && matchList.size() == 1) {
return temp;
}
}
return null;
}
/**
* Sets the acct level.
* @param current - The current
*
* @param current - The current
* @param validateList - The validate list
*/
private void setAcctLevel(EnterpriseAccountDto currentDto, List<EnterpriseAccountDto> validateDtoList) {
if(currentDto.getParentCode()==null || currentDto.getParentCode().isEmpty()) {
if (currentDto.getParentCode() == null || currentDto.getParentCode().isEmpty()) {
currentDto.setAcctLevel(1);
currentDto.setFullName(currentDto.getName());
return;
......@@ -1941,26 +1950,24 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
EnterpriseAccountDto parentDto = null;
Optional<EnterpriseAccountDto> ifparentDtoExist = validateDtoList.stream()
.filter(sa -> sa.getCode().equals(currentDto.getParentCode())).findAny();
if(ifparentDtoExist.isPresent()) {
if (ifparentDtoExist.isPresent()) {
parentDto = ifparentDtoExist.get();
}
if(parentDto!=null) {
if(parentDto.getAcctLevel()==null) {
if (parentDto != null) {
if (parentDto.getAcctLevel() == null) {
setAcctLevel(parentDto, validateDtoList);
}
currentDto.setAcctLevel(parentDto.getAcctLevel()+1);
if(currentDto.getName()!=null && !currentDto.getName().isEmpty()
currentDto.setAcctLevel(parentDto.getAcctLevel() + 1);
if (currentDto.getName() != null && !currentDto.getName().isEmpty()
&& !currentDto.getName().contains(parentDto.getFullName() + EnterpriseAccountConstant.FullNameSeparator)) {
currentDto.setFullName(parentDto.getFullName() + EnterpriseAccountConstant.FullNameSeparator + currentDto.getName());
}
else {
} else {
currentDto.setFullName(currentDto.getName());
}
}
else {
} else {
currentDto.setFullName(currentDto.getName());
}
}
}
......@@ -3,25 +3,22 @@ package pwc.taxtech.atms.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.ftp.FtpService;
import pwc.taxtech.atms.service.FileSystemService;
import java.io.InputStream;
@Service
public class FTPFileSystemServiceImpl implements FileSystemService {
public class FTPFileSystemServiceImpl {
private static final String USER_TEMPLATE_PATH = "pwc/userTemplate/";
@Autowired
private FtpService ftpService;
@Override
public String uploadUserTemplate(String fileName, InputStream inputStream) throws Exception {
ftpService.upload(USER_TEMPLATE_PATH, fileName, inputStream);
return USER_TEMPLATE_PATH + fileName;
}
@Override
public InputStream downloadUserTemplate(String filePath) throws Exception {
return ftpService.getFtpFileWithStaticUrl(filePath);
}
......
package pwc.taxtech.atms.service.impl;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dpo.ModelProfileDto;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dpo.ModelProfileDto;
import pwc.taxtech.atms.service.ModelConfigurationService;
@Service
public class ModelConfigurationServiceImpl extends AbstractService implements ModelConfigurationService {
public class ModelConfigurationServiceImpl extends AbstractService {
@Override
public List<ModelProfileDto> getModelListByIndustry(String serviceTypeId, String industryId) {
Map<String,Object> map = new HashMap<>(2);
map.put("serviceTypeId",serviceTypeId);
map.put("industryId",industryId);
return modelConfigMapper.getModelListByIndustry(map);
}
public List<ModelProfileDto> getModelListByIndustry(String serviceTypeId, String industryId) {
Map<String, Object> map = new HashMap<>(2);
map.put("serviceTypeId", serviceTypeId);
map.put("industryId", industryId);
return modelConfigMapper.getModelListByIndustry(map);
}
}
package pwc.taxtech.atms.service.impl;
import java.util.List;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.entity.Industry;
import pwc.taxtech.atms.service.ProjectIndustryService;
import java.util.List;
@Service
public class ProjectIndustryServiceImpl extends AbstractService implements ProjectIndustryService {
public class ProjectIndustryServiceImpl extends AbstractService {
@Override
public List<Industry> getAllAvailableIndustry() {
return industryMapper.getAllAvailableIndustry();
}
public List<Industry> getAllAvailableIndustry() {
return industryMapper.getAllAvailableIndustry();
}
}
package pwc.taxtech.atms.service.impl;
import java.util.List;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.entity.ServiceType;
import pwc.taxtech.atms.entity.ServiceTypeExample;
import pwc.taxtech.atms.service.ServiceTypeService;
import java.util.List;
@Service
public class ServiceTypeServiceImpl extends AbstractService implements ServiceTypeService {
public class ServiceTypeServiceImpl extends AbstractService {
@Override
public List<ServiceType> getServiceTypes() {
return serviceTypeMapper.selectByExample(new ServiceTypeExample());
}
public List<ServiceType> getServiceTypes() {
return serviceTypeMapper.selectByExample(new ServiceTypeExample());
}
}
package pwc.taxtech.atms.service.impl;
import static java.util.Comparator.comparing;
import static java.util.Comparator.naturalOrder;
import static java.util.Comparator.nullsFirst;
import static java.util.Comparator.nullsLast;
import static java.util.stream.Collectors.toList;
import static org.springframework.util.StringUtils.hasText;
import static pwc.taxtech.atms.common.CommonUtils.copyProperties;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.nutz.lang.Lang;
import org.nutz.lang.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dpo.StatisticAttributeDisplayDto;
import pwc.taxtech.atms.exception.ApplicationException;
import pwc.taxtech.atms.common.CommonConstants;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.OperateLogType;
import pwc.taxtech.atms.common.OperationAction;
import pwc.taxtech.atms.common.OperationModule;
import pwc.taxtech.atms.constant.DimensionConstant;
import pwc.taxtech.atms.dpo.StatisticAttributeDisplayDto;
import pwc.taxtech.atms.dto.OperationLogDto;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.StatisticAttributeDimensionDto;
......@@ -38,10 +21,22 @@ import pwc.taxtech.atms.entity.StatisticAttribute;
import pwc.taxtech.atms.entity.StatisticAttributeDimension;
import pwc.taxtech.atms.entity.StatisticAttributeDimensionExample;
import pwc.taxtech.atms.entity.StatisticAttributeExample;
import pwc.taxtech.atms.service.DictionaryService;
import pwc.taxtech.atms.exception.ApplicationException;
import pwc.taxtech.atms.service.DimensionService;
import pwc.taxtech.atms.service.StatisticAttributeService;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static java.util.Comparator.*;
import static java.util.stream.Collectors.toList;
import static org.springframework.util.StringUtils.hasText;
import static pwc.taxtech.atms.common.CommonUtils.copyProperties;
/**
*/
@Service
......@@ -50,7 +45,7 @@ public class StatisticAttributeServiceImpl extends AbstractService implements St
@Autowired
private DimensionService dimensionService;
@Autowired
private DictionaryService dictionaryService;
private DictionaryServiceImpl dictionaryService;
@Override
public List<StatisticAttributeDisplayDto> getStatisticAttributeListByDimensionId(String parentDimensionId,
......
......@@ -8,16 +8,14 @@ import org.apache.poi.xssf.usermodel.XSSFEvaluationWorkbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.service.TemplateFormulaService;
@Service
public class TemplateFormulaServiceImpl extends AbstractService implements TemplateFormulaService {
public class TemplateFormulaServiceImpl extends AbstractService {
private FormulaHelper formulaHelper = new FormulaHelper();
//private static ScriptEngine m_engine = Python.CreateEngine();
@Override
public OperationResultDto validate(String formula) {
OperationResultDto result = new OperationResultDto();
......
......@@ -20,14 +20,14 @@ import pwc.taxtech.atms.common.POIUtil;
import pwc.taxtech.atms.common.message.ErrorMessage;
import pwc.taxtech.atms.common.message.TemplateMessage;
import pwc.taxtech.atms.constant.enums.TemplateGroupType;
import pwc.taxtech.atms.dao.CellTemplateConfigMapper;
import pwc.taxtech.atms.dao.CellTemplateMapper;
import pwc.taxtech.atms.dao.TemplateGroupMapper;
import pwc.taxtech.atms.dao.TemplateMapper;
import pwc.taxtech.atms.dao.CellTemplateConfigDao;
import pwc.taxtech.atms.dao.CellTemplateConfigMapper;
import pwc.taxtech.atms.dao.CellTemplateDao;
import pwc.taxtech.atms.dao.CellTemplateMapper;
import pwc.taxtech.atms.dao.TemplateDao;
import pwc.taxtech.atms.dao.TemplateGroupDao;
import pwc.taxtech.atms.dao.TemplateGroupMapper;
import pwc.taxtech.atms.dao.TemplateMapper;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.TemplateGroupDto;
import pwc.taxtech.atms.entity.CellTemplate;
......@@ -39,7 +39,6 @@ import pwc.taxtech.atms.entity.TemplateExample;
import pwc.taxtech.atms.entity.TemplateGroup;
import pwc.taxtech.atms.entity.TemplateGroupExample;
import pwc.taxtech.atms.exception.ServiceException;
import pwc.taxtech.atms.service.FileSystemService;
import pwc.taxtech.atms.service.TemplateGroupService;
import java.io.ByteArrayInputStream;
......@@ -56,7 +55,7 @@ import java.util.stream.Collectors;
@Service
public class TemplateGroupServiceImpl extends AbstractService implements TemplateGroupService {
@Autowired
private FileSystemService fileSystemService;
private FTPFileSystemServiceImpl fileSystemService;
@Autowired
private TemplateGroupDao templateGroupDao;
@Autowired
......
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