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,29 +15,37 @@ 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;
......@@ -56,37 +56,33 @@ 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,
@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) {
......
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;
ProjectIndustryServiceImpl projectIndustryService;
@RequestMapping(value = "getAllAvailableIndustry", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody List<Industry> getAllAvailableIndustry() {
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;
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,
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,32 +2,37 @@ 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) {
//set default value
if(bOverwrite == null) {
if (bOverwrite == null) {
bOverwrite = true;
}
if(acctLevel == null) {
if (acctLevel == null) {
acctLevel = 0;
}
......@@ -37,17 +42,16 @@ public class AccountServiceImpl extends AbstractService implements AccountServic
}
//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);
}
......@@ -55,6 +59,7 @@ public class AccountServiceImpl extends AbstractService implements AccountServic
/**
* 删除对应关系
*
* @param epAccountCode
* @param enterpriseAccountSetId
* @param organizaionId
......@@ -75,6 +80,7 @@ public class AccountServiceImpl extends AbstractService implements AccountServic
/**
* 插入对应关系到对应关系表
*
* @param epAccountCode
* @param enterpriseAccountSetId
* @param stdAccountCode
......@@ -99,7 +105,7 @@ public class AccountServiceImpl extends AbstractService implements AccountServic
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
......@@ -58,7 +38,6 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
* String)
*/
@SuppressWarnings("rawtypes")
@Override
public DataInitDto validateAndImportInitData(String filePath) {
logger.debug("enter DataInitServiceImpl validateImportInitData");
InputStream savedInputStream = Files.findFileAsStream(filePath);
......@@ -199,7 +178,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
List<OrganizationStructure> importOrgStructureList = new ArrayList<>();
for (Map map : dataMapCollection) {
if(map.get("层级名称") == null || map.get("使用状态") == null) {
if (map.get("层级名称") == null || map.get("使用状态") == null) {
continue;
}
......@@ -250,13 +229,13 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
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();
......@@ -277,15 +256,15 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
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());
......@@ -368,10 +347,10 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
}
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;
......@@ -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();
......@@ -476,7 +455,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
// 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())) {
......@@ -493,11 +472,11 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
//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());
......@@ -507,7 +486,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
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());
......@@ -516,7 +495,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
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());
......@@ -527,7 +506,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
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());
......@@ -536,7 +515,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
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());
......@@ -576,7 +555,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
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;
}
......@@ -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();
......@@ -645,7 +624,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
// 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;
}
......@@ -673,7 +652,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
List<OrganizationStructure> orgStructureList = new ArrayList<>();
//if headers are valid
if(dataInitDto.getIsImportOrgStructureValid()) {
if (dataInitDto.getIsImportOrgStructureValid()) {
/*
* 目前采用逐条插入的方法, 如今后数据量大可改用批量插入, 但需要加入数据校验
*/
......@@ -690,7 +669,7 @@ 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("导入机构层级错误");
}
}
......@@ -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()) {
/*
* 目前采用逐条插入的方法, 如今后数据量大可改用批量插入, 但需要加入数据校验
*/
......@@ -726,7 +705,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
DataCountDto dataCountDto = new DataCountDto(businessUnitList.size(), originalCount, newCount, errorCount, "事业部");
dataInitDto.getValidMsgs().add(dataCountDto);
if(errorCount > 0) {
if (errorCount > 0) {
dataInitDto.getErrorMsgs().add("导入事业部错误");
}
}
......@@ -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,7 +762,7 @@ 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("导入区域错误");
}
}
......@@ -799,7 +778,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
Long originalCount = enterpriseAccountMapper.countByExample(null);
List<EnterpriseAccount> enterpriseAccountList = new ArrayList<>();
if(dataInitDto.getIsImportEnterpriseAccountValid()) {
if (dataInitDto.getIsImportEnterpriseAccountValid()) {
/*
* 准备数据时需要通过非空校验
*/
......@@ -819,7 +798,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
DataCountDto dataCountDto = new DataCountDto(enterpriseAccountList.size(), originalCount, newCount, errorCount, "企业科目");
dataInitDto.getValidMsgs().add(dataCountDto);
if(errorCount > 0) {
if (errorCount > 0) {
dataInitDto.getErrorMsgs().add("导入企业科目错误");
}
}
......@@ -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()) {
/*
* 准备数据时需要通过非空校验
*/
......@@ -855,7 +834,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
DataCountDto dataCountDto = new DataCountDto(customerList.size(), originalCount, newCount, errorCount, "客户列表");
dataInitDto.getValidMsgs().add(dataCountDto);
if(errorCount > 0) {
if (errorCount > 0) {
dataInitDto.getErrorMsgs().add("导入客户列表错误");
}
}
......@@ -871,7 +850,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
Long originalCount = organizationMapper.countByExample(null);
List<Organization> organizationList = new ArrayList<>();
if(dataInitDto.getIsImportOrganizationValid()) {
if (dataInitDto.getIsImportOrganizationValid()) {
RegionExample regionExample = new RegionExample();
regionExample.setOrderByClause("LevelType DESC");
/*
......@@ -893,13 +872,14 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
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()) {
/*
* 准备数据时需要通过非空校验
*/
......@@ -926,7 +906,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
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()) {
/*
* 准备数据时需要通过非空校验
*/
......@@ -970,7 +951,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
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);
......@@ -1007,7 +988,7 @@ public class DataInitServiceImpl extends AbstractService implements DataInitServ
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
......@@ -75,7 +84,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
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);
}
/*
......@@ -95,7 +104,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
List<EnterpriseAccount> epAccounts = enterpriseAccountMapper.selectByExample(enterpriseAccountExample);
//no enterprise account
if(epAccounts==null || epAccounts.isEmpty()) {
if (epAccounts == null || epAccounts.isEmpty()) {
return new EnterpriseAccountAndValidateInfo();
}
......@@ -105,7 +114,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
//set stdName
List<EnterpriseAccountDto> epAccountDtoList = new ArrayList<>();
for(EnterpriseAccount epAccount: epAccounts) {
for (EnterpriseAccount epAccount : epAccounts) {
EnterpriseAccountDto epAccountDto = new EnterpriseAccountDto();
CommonUtils.copyProperties(epAccount, epAccountDto);
......@@ -113,7 +122,9 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
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);
}
......@@ -122,15 +133,15 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
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);
}
}
......@@ -167,7 +178,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
EnterpriseAccountDto enterpriseAccountDto = new EnterpriseAccountDto();
CommonUtils.copyProperties(enterpriseAccount, enterpriseAccountDto);
epAccounts.stream().filter(epAccount -> enterpriseAccount.getParentCode()!=null && enterpriseAccount.getParentCode().equals(epAccount.getCode())).findFirst()
epAccounts.stream().filter(epAccount -> enterpriseAccount.getParentCode() != null && enterpriseAccount.getParentCode().equals(epAccount.getCode())).findFirst()
.ifPresent(epAccount -> {
enterpriseAccountDto.setParentName(epAccount.getName());
enterpriseAccountDto.setParentFullName(epAccount.getFullName());
......@@ -189,7 +200,7 @@ 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();
......@@ -197,7 +208,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
//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
......@@ -221,7 +232,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
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);
}
......@@ -251,18 +262,18 @@ 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);
}
......@@ -270,7 +281,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
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());
......@@ -284,9 +295,9 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
.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);
......@@ -313,8 +324,8 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
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}";
......@@ -375,12 +386,12 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
.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;
}
......@@ -390,7 +401,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
.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);
......@@ -399,26 +410,26 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
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);
}
......@@ -430,7 +441,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
standardAccountExample.createCriteria()
.andCodeIn(uniqueStdCodeList).andIndustryIdEqualTo(industryId);
List<StandardAccount> standardAccountList = standardAccountMapper.selectByExample(standardAccountExample);
if(CollectionUtils.isEmpty(standardAccountList)) {
if (CollectionUtils.isEmpty(standardAccountList)) {
continue;
}
List<String> distinctStdParentCodeList = standardAccountList.stream()
......@@ -438,34 +449,30 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
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)
......@@ -504,12 +511,12 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
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;
}
......@@ -537,7 +544,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
operationLogService.addOrDeleteDataAddLog(updateLogParams);
//nothing to import
if(importData == null && CollectionUtils.isEmpty(importData)) {
if (importData == null && CollectionUtils.isEmpty(importData)) {
return OperationResultDto.success();
}
......@@ -572,15 +579,15 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
.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());
}
}
......@@ -592,6 +599,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
/**
* Generate by-level wrapped enterprise Account list
*
* @param currentEpAccountDto
* @param epAccountDtoList
* @return List<EnterpriseAccountDto>
......@@ -603,14 +611,14 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
.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);
}
}
......@@ -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
*/
......@@ -1355,13 +1363,14 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
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
*/
......@@ -1373,10 +1382,10 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
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);
}
}
......@@ -1385,6 +1394,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
/**
* Validates if there is any account with wrong direction value
*
* @param epAccountList
* @return ValidateInfoDto
*/
......@@ -1405,6 +1415,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
/**
* Validates if there is any account with wrong accprop value
*
* @param epAccountList
* @return ValidateInfoDto
*/
......@@ -1415,7 +1426,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
List<String> inValidateCodeList = epAccountList.stream()
.filter(epAccount ->
epAccount.getAcctProp()!=null && (epAccount.getAcctProp() > EnterpriseAccountConstant.MaxAcctPropValue || (epAccount.getAcctProp() < EnterpriseAccountConstant.MinAcctPropValue && epAccount.getAcctProp() != EnterpriseAccountConstant.SpecialAcctPropValue)))
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);
......@@ -1425,6 +1436,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
/**
* Validates if there is any account with null accprop value
*
* @param epAccountList
* @return ValidateInfoDto
*/
......@@ -1435,7 +1447,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
List<String> inValidateCodeList = epAccountList.stream()
.filter(epAccount ->
epAccount.getAcctProp()==null)
epAccount.getAcctProp() == null)
.map(epAccount -> epAccount.getCode())
.distinct().collect(Collectors.toList());
validateInfoDto.setInValidateCodeList(inValidateCodeList);
......@@ -1445,6 +1457,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
/**
* Validates if there is any account with empty name
*
* @param epAccountList
* @return ValidateInfoDto
*/
......@@ -1464,6 +1477,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
/**
* Validates if there is any account with empty name
*
* @param epAccountList
* @return ValidateInfoDto
*/
......@@ -1472,13 +1486,13 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
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) {
if (!parentExist) {
validateInfoDto.addInValidateCode(accountWithParent.getCode());
}
}
......@@ -1489,10 +1503,11 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
/**
* 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;
......@@ -1500,7 +1515,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
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())
......@@ -1508,22 +1523,22 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
.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);
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("");
......@@ -1547,24 +1561,25 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
/**
* Sets the parent is not leaf.
*
* @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);
......@@ -1587,18 +1602,19 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
/**
* Sets the parent leaf.
*
* @param parentCode - The parentcode
* @param enterpriseAccountSetId
* @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;
}
......@@ -1613,7 +1629,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
.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);
......@@ -1635,6 +1651,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
/**
* 通过Parent企业科目对象获取该ParentCode下面的所有子企业科目
*
* @param parentCode - Parent企业科目代码
* @param accountSetId - 企业账套Id
* @param industryId - 行业Id
......@@ -1645,31 +1662,25 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
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());
}
}
......@@ -1681,7 +1692,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
private void enableEnterpriseAccountSet(String enterpriseAccountSetId) {
EnterpriseAccountSet enterpriseAccountSet = enterpriseAccountSetMapper.selectByPrimaryKey(enterpriseAccountSetId);
if(enterpriseAccountSet.getIsActive()) {
if (enterpriseAccountSet.getIsActive()) {
return;
}
......@@ -1701,8 +1712,8 @@ 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);
}
......@@ -1727,10 +1738,10 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
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;
}
......@@ -1743,65 +1754,63 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
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);
......@@ -1816,7 +1825,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
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
......@@ -1824,20 +1833,20 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
//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);
}
......@@ -1855,7 +1864,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
*/
private List<EnterpriseAccount> transform(List<EnterpriseAccountDto> importData, String enterpriseAccountSetId) {
if(CollectionUtils.isEmpty(importData)) {
if (CollectionUtils.isEmpty(importData)) {
return new ArrayList<>();
}
importData.stream().forEach(account -> {
......@@ -1871,25 +1880,23 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
//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);
}
}
......@@ -1910,16 +1917,17 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
/**
* 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;
}
}
......@@ -1928,12 +1936,13 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
/**
* Sets the acct level.
*
* @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,24 +1950,22 @@ 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);
currentDto.setAcctLevel(parentDto.getAcctLevel() + 1);
if(currentDto.getName()!=null && !currentDto.getName().isEmpty()
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);
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();
}
......
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());
}
......
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