Commit 2af32692 authored by neo's avatar neo

[DEL] delete enterprise account set service interface

parent e8d180c5
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 java.util.List;
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;
......@@ -26,57 +17,71 @@ 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.common.CommonUtils;
import pwc.taxtech.atms.common.message.ErrorMessage;
import pwc.taxtech.atms.constant.EnterpriseAccountConstant;
import pwc.taxtech.atms.dpo.EnterpriseAccountDto;
import pwc.taxtech.atms.dpo.EnterpriseAccountSetOrgDto;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.epaccount.AccountMapDto;
import pwc.taxtech.atms.dto.epaccount.AccountMappingDto;
import pwc.taxtech.atms.dto.epaccount.EnterpriseAccountAndValidateInfo;
import pwc.taxtech.atms.dto.epaccount.EnterpriseAccountSetDto;
import pwc.taxtech.atms.dto.epaccount.EnterpriseAccountUploadDto;
import pwc.taxtech.atms.exception.ApplicationException;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.message.ErrorMessage;
import pwc.taxtech.atms.constant.EnterpriseAccountConstant;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.service.EnterpriseAccountService;
import pwc.taxtech.atms.service.EnterpriseAccountSetService;
import pwc.taxtech.atms.service.impl.EnterpriseAccountSetServiceImpl;
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;
import java.util.List;
@RestController
@RequestMapping("/api/v1/enterpriseAccountManage")
public class EnterpriseAccountManagerController {
private static final Logger logger = LoggerFactory.getLogger(EnterpriseAccountManagerController.class);
@Autowired private EnterpriseAccountSetService enterpriseAccountSetService;
@Autowired private EnterpriseAccountService enterpriseAccountService;
@Autowired private FileService fileService;
@Autowired
private EnterpriseAccountSetServiceImpl enterpriseAccountSetService;
@Autowired
private EnterpriseAccountService enterpriseAccountService;
@Autowired
private FileService fileService;
@ApiOperation(value = "Get the enterprise account set list")
@RequestMapping(value = { "/getEnterpriseAccountSetList" }, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody List<EnterpriseAccountSetDto> getEnterpriseAccountSetList() {
@RequestMapping(value = {"/getEnterpriseAccountSetList"}, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
List<EnterpriseAccountSetDto> getEnterpriseAccountSetList() {
return enterpriseAccountSetService.getEnterpriseAccountSetList();
}
@ApiOperation(value = "Gets the enterprise account set")
@RequestMapping(value = { "/getEnterpriseAccountSet" }, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody EnterpriseAccountSetDto getEnterpriseAccountSet(@RequestParam String id) {
@RequestMapping(value = {"/getEnterpriseAccountSet"}, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
EnterpriseAccountSetDto getEnterpriseAccountSet(@RequestParam String id) {
return enterpriseAccountSetService.getEnterpriseAccountSet(id);
}
@SuppressWarnings("rawtypes")
@ApiOperation(value = "Updates the enterprise account set")
@RequestMapping(value = { "/updateEnterpriseAccountSet" }, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody OperationResultDto updateEnterpriseAccountSet(@RequestBody EnterpriseAccountSetDto enterpriseAccountSetDto) {
@RequestMapping(value = {"/updateEnterpriseAccountSet"}, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
OperationResultDto updateEnterpriseAccountSet(@RequestBody EnterpriseAccountSetDto enterpriseAccountSetDto) {
return enterpriseAccountSetService.updateEnterpriseAccountSet(enterpriseAccountSetDto);
}
@SuppressWarnings("rawtypes")
@ApiOperation(value = "Enterprises the account set name validate")
@RequestMapping(value = { "/enterpriseAccountSetNameValidate" }, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody OperationResultDto enterpriseAccountSetNameValidate(@RequestParam String id, @RequestParam String name) {
@RequestMapping(value = {"/enterpriseAccountSetNameValidate"}, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
OperationResultDto enterpriseAccountSetNameValidate(@RequestParam String id, @RequestParam String name) {
EnterpriseAccountSetDto enterpriseAccountSetDto = new EnterpriseAccountSetDto();
enterpriseAccountSetDto.setId(id);
enterpriseAccountSetDto.setName(name);
......@@ -85,8 +90,9 @@ public class EnterpriseAccountManagerController {
@SuppressWarnings("rawtypes")
@ApiOperation(value = "Enterprises the account set code validate")
@RequestMapping(value = { "/enterpriseAccountSetCodeValidate" }, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody OperationResultDto enterpriseAccountSetCodeValidate(@RequestParam String id, @RequestParam String code) {
@RequestMapping(value = {"/enterpriseAccountSetCodeValidate"}, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
OperationResultDto enterpriseAccountSetCodeValidate(@RequestParam String id, @RequestParam String code) {
EnterpriseAccountSetDto enterpriseAccountSetDto = new EnterpriseAccountSetDto();
enterpriseAccountSetDto.setId(id);
enterpriseAccountSetDto.setCode(code);
......@@ -95,34 +101,38 @@ public class EnterpriseAccountManagerController {
@SuppressWarnings("rawtypes")
@ApiOperation(value = "Enterprises the account set org validate")
@RequestMapping(value = { "/enterpriseAccountSetOrgValidate" }, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody OperationResultDto enterpriseAccountSetOrgValidate(@RequestBody EnterpriseAccountSetDto enterpriseAccountSetDto) {
@RequestMapping(value = {"/enterpriseAccountSetOrgValidate"}, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
OperationResultDto enterpriseAccountSetOrgValidate(@RequestBody EnterpriseAccountSetDto enterpriseAccountSetDto) {
return enterpriseAccountSetService.enterpriseAccountSetOrgValidate(enterpriseAccountSetDto);
}
@SuppressWarnings("rawtypes")
@ApiOperation(value = "Add the oganization link to an enterprises account set")
@RequestMapping(value = { "/addEnterpriseAccountSetOrg" }, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody OperationResultDto addEnterpriseAccountSetOrg(@RequestBody EnterpriseAccountSetDto enterpriseAccountSetDto) {
@RequestMapping(value = {"/addEnterpriseAccountSetOrg"}, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
OperationResultDto addEnterpriseAccountSetOrg(@RequestBody EnterpriseAccountSetDto enterpriseAccountSetDto) {
return enterpriseAccountSetService.addEnterpriseAccountSetOrg(enterpriseAccountSetDto);
}
@SuppressWarnings("rawtypes")
@ApiOperation(value = "Update the oganization link to an enterprises account set")
@RequestMapping(value = { "/updateEnterpriseAccountSetOrg" }, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody OperationResultDto updateEnterpriseAccountSetOrg(@RequestBody EnterpriseAccountSetOrgDto enterpriseAccountSetOrgDto) {
@RequestMapping(value = {"/updateEnterpriseAccountSetOrg"}, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
OperationResultDto updateEnterpriseAccountSetOrg(@RequestBody EnterpriseAccountSetOrgDto enterpriseAccountSetOrgDto) {
return enterpriseAccountSetService.updateEnterpriseAccountSetOrg(enterpriseAccountSetOrgDto);
}
@SuppressWarnings("rawtypes")
@ApiOperation(value = "Delete the oganization link to an enterprises account set")
@RequestMapping(value = { "/deleteEnterpriseAccountSetOrg" }, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody OperationResultDto deleteEnterpriseAccountSetOrg(@RequestBody EnterpriseAccountSetDto enterpriseAccountSetDto) {
@RequestMapping(value = {"/deleteEnterpriseAccountSetOrg"}, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
OperationResultDto deleteEnterpriseAccountSetOrg(@RequestBody EnterpriseAccountSetDto enterpriseAccountSetDto) {
return enterpriseAccountSetService.deleteEnterpriseAccountSetOrg(enterpriseAccountSetDto);
}
@ApiOperation(value = "Download Enterprise account template")
@RequestMapping(value = { "/downEntepriseAccountTemplate" }, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RequestMapping(value = {"/downEntepriseAccountTemplate"}, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public void downEntepriseAccountTemplate(HttpServletResponse response) {
String filePath;
......@@ -133,29 +143,24 @@ public class EnterpriseAccountManagerController {
templateFile = new File(filePath + EnterpriseAccountConstant.EnterpriseAccountTemplate);
inputStream = new BufferedInputStream(new FileInputStream(templateFile));
String customFileName = EnterpriseAccountConstant.EntepriseAccountFileName + 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 " + EnterpriseAccountConstant.EnterpriseAccountTemplate);
throw new ApplicationException("Tempate file not found.");
}
catch (Exception e) {
} catch (Exception e) {
logger.error("Error downloading template file " + EnterpriseAccountConstant.EntepriseAccountFileName + ".xlsx", e);
throw new ApplicationException("Error downloading template file " + EnterpriseAccountConstant.EntepriseAccountFileName + ".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;
}
}
......@@ -163,8 +168,9 @@ public class EnterpriseAccountManagerController {
@SuppressWarnings("rawtypes")
@ApiOperation(value = "Upload and save enterprise accounts.")
@RequestMapping(value = { "/Upload" }, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody OperationResultDto uploadEnterpriseAccount(@ModelAttribute EnterpriseAccountUploadDto uploadForm,
@RequestMapping(value = {"/Upload"}, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
OperationResultDto uploadEnterpriseAccount(@ModelAttribute EnterpriseAccountUploadDto uploadForm,
@RequestParam(value = "file", required = false) CommonsMultipartFile inputFile) {
if (inputFile == null || inputFile.getSize() <= 0) {
......@@ -190,23 +196,23 @@ public class EnterpriseAccountManagerController {
//validate file
OperationResultDto<List<EnterpriseAccountDto>> validateResult = enterpriseAccountService.validateImportEnterpriseAccount(filePath);
if(!validateResult.getResult()) {
if (!validateResult.getResult()) {
return validateResult;
}
//import
String enterpriseAccountSetId = uploadForm.getEnterpriseAccountSetId();
//创建新账套
if(enterpriseAccountSetId == null || enterpriseAccountSetId.isEmpty()) {
if (enterpriseAccountSetId == null || enterpriseAccountSetId.isEmpty()) {
logger.debug("Uploading and save enterprise account set. "
+ "[name=" + uploadForm.getName()+", code=" + uploadForm.getCode()
+ "[name=" + uploadForm.getName() + ", code=" + uploadForm.getCode()
+ ", selectedOrgList=" + uploadForm.getSelectedOrgList() + ", isImportAppend=" + uploadForm.getIsImportAppend() + ".]");
enterpriseAccountService.addEnterpriseAccountSetAndImportData(uploadForm.getName(), uploadForm.getCode(), validateResult.getData());
}
//仅仅上传科目
else {
logger.debug("Uploading enterprise account. "
+ "[accountset id=" + uploadForm.getEnterpriseAccountSetId() + ", name=" + uploadForm.getName()+", code=" + uploadForm.getCode()
+ "[accountset id=" + uploadForm.getEnterpriseAccountSetId() + ", name=" + uploadForm.getName() + ", code=" + uploadForm.getCode()
+ ", selectedOrgList=" + uploadForm.getSelectedOrgList() + ", isImportAppend=" + uploadForm.getIsImportAppend() + ".]");
EnterpriseAccountSetDto enterpriseAccountSetDto = new EnterpriseAccountSetDto();
enterpriseAccountSetDto.setId(uploadForm.getEnterpriseAccountSetId());
......@@ -219,55 +225,60 @@ public class EnterpriseAccountManagerController {
}
@ApiOperation(value = "Gets the list by enterprise account set identifier.")
@RequestMapping(value = { "/getListByEnterpriseAccountSetID" }, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RequestMapping(value = {"/getListByEnterpriseAccountSetID"}, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
EnterpriseAccountAndValidateInfo getListByEnterpriseAccountSetId(@RequestParam String enterpriseAccountSetID) {
return enterpriseAccountService.getListByEnterpriseAccountSetId(enterpriseAccountSetID);
}
@ApiOperation(value = "Gets the specified enterprise account by identifier")
@RequestMapping(value = { "/getsingle" }, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody EnterpriseAccountDto getEnterpriseAccount(@RequestParam String id) {
@RequestMapping(value = {"/getsingle"}, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
EnterpriseAccountDto getEnterpriseAccount(@RequestParam String id) {
return enterpriseAccountService.getEnterpriseAccount(id);
}
@ApiOperation(value = "Add an enterprise account")
@RequestMapping(value = { "/add" }, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody OperationResultDto<List<EnterpriseAccountDto>> addEnterpriseAccount(@RequestBody EnterpriseAccountDto enterpriseAccountDto) {
@RequestMapping(value = {"/add"}, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
OperationResultDto<List<EnterpriseAccountDto>> addEnterpriseAccount(@RequestBody EnterpriseAccountDto enterpriseAccountDto) {
return enterpriseAccountService.addEnterpriseAccount(enterpriseAccountDto);
}
@ApiOperation(value = "Update an enterprise account")
@RequestMapping(value = { "/update" }, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody OperationResultDto<List<EnterpriseAccountDto>> updateEnterpriseAccount(@RequestBody EnterpriseAccountDto enterpriseAccountDto) {
@RequestMapping(value = {"/update"}, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
OperationResultDto<List<EnterpriseAccountDto>> updateEnterpriseAccount(@RequestBody EnterpriseAccountDto enterpriseAccountDto) {
return enterpriseAccountService.updateEnterpriseAccount(enterpriseAccountDto);
}
@SuppressWarnings("rawtypes")
@ApiOperation(value = "一键删除重复企业科目")
@RequestMapping(value = { "/clearRepeatEnterpriseAccountList" }, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody OperationResultDto clearRepeatEnterpriseAccountList(@RequestBody EnterpriseAccountSetDto enterpriseAccountSetDto) {
@RequestMapping(value = {"/clearRepeatEnterpriseAccountList"}, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
OperationResultDto clearRepeatEnterpriseAccountList(@RequestBody EnterpriseAccountSetDto enterpriseAccountSetDto) {
return enterpriseAccountService.clearRepeatEnterpriseAccountList(enterpriseAccountSetDto);
}
@ApiOperation(value = "获取企业账套Mapping")
@RequestMapping(value = { "/getAccountMappingOrg" }, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody List<AccountMappingDto> getAccountMappingOrg(@RequestParam(name="organizationID") String organizationId) {
@RequestMapping(value = {"/getAccountMappingOrg"}, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public @ResponseBody
List<AccountMappingDto> getAccountMappingOrg(@RequestParam(name = "organizationID") String organizationId) {
return enterpriseAccountService.getAccountMappingOrg(organizationId);
}
@ResponseBody
@ApiOperation(value = "按组织机构查找")
@RequestMapping(value = "getEnterpriseAccountSetListByOrgID", method = RequestMethod.GET)
public List<EnterpriseAccountSetDto> getEnterpriseAccountSetListByOrgId(@RequestParam(name="orgID") String orgId) {
public List<EnterpriseAccountSetDto> getEnterpriseAccountSetListByOrgId(@RequestParam(name = "orgID") String orgId) {
return enterpriseAccountService.getEnterpriseAccountSetListByOrgId(orgId);
}
@ResponseBody
@ApiOperation(value = "科目对应列表")
@RequestMapping(value = "getEnterpriseAccountList", method = RequestMethod.GET)
public List<EnterpriseAccountDto> getEnterpriseAccountList(@RequestParam(name="espID") String espId,
@RequestParam(name="orgID") String orgId,
public List<EnterpriseAccountDto> getEnterpriseAccountList(@RequestParam(name = "espID") String espId,
@RequestParam(name = "orgID") String orgId,
@RequestParam String filterType) {
return enterpriseAccountService.getList(espId, orgId, filterType);
}
......
package pwc.taxtech.atms.service;
import java.util.List;
import pwc.taxtech.atms.dpo.EnterpriseAccountSetOrgDto;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.epaccount.EnterpriseAccountSetDto;
public interface EnterpriseAccountSetService {
/**
* 获取所有的账套
* @return List<EnterpriseAccountSetDto>
*/
List<EnterpriseAccountSetDto> getEnterpriseAccountSetList();
/**
* Gets the enterprise account set detail, including organizations using this account set
* @param enterpriseAccountSetId - The identifier
* @return
*/
EnterpriseAccountSetDto getEnterpriseAccountSet(String enterpriseAccountSetId);
/**
* Updates the enterprise account set.
*
* @param enterpriseAccountSetDto
* @return OperationResultDto
*/
@SuppressWarnings("rawtypes")
OperationResultDto updateEnterpriseAccountSet(EnterpriseAccountSetDto enterpriseAccountSetDto);
/**
* Validate EnterpriseAccountSet name, check if it is duplicated
* @param enterpriseAccountSetDto
* @return OperationResultDto
*/
@SuppressWarnings("rawtypes")
OperationResultDto enterpriseAccountSetNameValidate(EnterpriseAccountSetDto enterpriseAccountSetDto);
/**
* Validate EnterpriseAccountSet code, check if it is duplicated
* @param enterpriseAccountSetDto
* @return OperationResultDto
*/
@SuppressWarnings("rawtypes")
OperationResultDto enterpriseAccountSetCodeValidate(EnterpriseAccountSetDto enterpriseAccountSetDto);
/**
* Enterprises the account set org validate.
* @param enterpriseAccountSetDto
* @return OperationResultDto
*/
@SuppressWarnings("rawtypes")
OperationResultDto enterpriseAccountSetOrgValidate(EnterpriseAccountSetDto enterpriseAccountSetDto);
/**
* 添加关联机构
* @param enterpriseAccountSetDto
* @return OperationResultDto
*/
@SuppressWarnings("rawtypes")
OperationResultDto addEnterpriseAccountSetOrg(EnterpriseAccountSetDto enterpriseAccountSetDto);
/**
* 更新关联机构
* @param enterpriseAccountSetOrgDto
* @return
*/
@SuppressWarnings("rawtypes")
OperationResultDto updateEnterpriseAccountSetOrg(EnterpriseAccountSetOrgDto enterpriseAccountSetOrgDto);
/**
* Delete organiztion link with one enterpriseAccountSet
* @param enterpriseAccountSetDto
* @return OperationResultDto
*/
@SuppressWarnings("rawtypes")
OperationResultDto deleteEnterpriseAccountSetOrg(EnterpriseAccountSetDto enterpriseAccountSetDto);
}
......@@ -42,7 +42,6 @@ import pwc.taxtech.atms.dto.epaccount.EnterpriseAccountSetDto;
import pwc.taxtech.atms.dto.stdaccount.StandardAccountDto;
import pwc.taxtech.atms.entity.*;
import pwc.taxtech.atms.service.EnterpriseAccountService;
import pwc.taxtech.atms.service.EnterpriseAccountSetService;
import java.io.InputStream;
import java.util.*;
......@@ -54,7 +53,7 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
@Autowired
private AccountServiceImpl accountService;
@Autowired
private EnterpriseAccountSetService enterpriseAccountSetService;
private EnterpriseAccountSetServiceImpl enterpriseAccountSetService;
@Autowired
private FileService fileService;
@Autowired
......
......@@ -25,7 +25,6 @@ import pwc.taxtech.atms.entity.EnterpriseAccountSetOrg;
import pwc.taxtech.atms.entity.EnterpriseAccountSetOrgExample;
import pwc.taxtech.atms.entity.EnterpriseAccountSetOrgExample.Criteria;
import pwc.taxtech.atms.entity.Organization;
import pwc.taxtech.atms.service.EnterpriseAccountSetService;
import pwc.taxtech.atms.service.OperationLogService;
import java.util.ArrayList;
......@@ -34,15 +33,20 @@ import java.util.Map;
import java.util.stream.Collectors;
@Service
public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetService {
public class EnterpriseAccountSetServiceImpl {
@Autowired private EnterpriseAccountSetMapper enterpriseAccountSetMapper;
@Autowired private EnterpriseAccountSetOrgMapper enterpriseAccountSetOrgMapper;
@Autowired private OrganizationMapper organizationMapper;
@Autowired
private EnterpriseAccountSetMapper enterpriseAccountSetMapper;
@Autowired
private EnterpriseAccountSetOrgMapper enterpriseAccountSetOrgMapper;
@Autowired
private OrganizationMapper organizationMapper;
@Autowired private OperationLogService operationLogService;
@Autowired
private OperationLogService operationLogService;
@Autowired private AuthUserHelper authUserHelper;
@Autowired
private AuthUserHelper authUserHelper;
/*
......@@ -51,7 +55,6 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
* @see pwc.taxtech.atms.service.EnterpriseAccountSetService#
* getEnterpriseAccountSetList()
*/
@Override
public List<EnterpriseAccountSetDto> getEnterpriseAccountSetList() {
EnterpriseAccountSetExample example = new EnterpriseAccountSetExample();
......@@ -67,7 +70,6 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
* pwc.taxtech.atms.service.EnterpriseAccountService#GetEnterpriseAccountSet(
* java.lang.String)
*/
@Override
public EnterpriseAccountSetDto getEnterpriseAccountSet(String enterpriseAccountSetId) {
EnterpriseAccountSet enterpriseAccountSet = enterpriseAccountSetMapper
.selectByPrimaryKey(enterpriseAccountSetId);
......@@ -92,9 +94,9 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
EnterpriseAccountSetOrgDto enterpriseAccountSetOrgDto = new EnterpriseAccountSetOrgDto();
CommonUtils.copyProperties(entity, enterpriseAccountSetOrgDto);
enterpriseAccountSetOrgDto.setEffectiveDateStr(
enterpriseAccountSetOrgDto.getEffectiveDate()==null ? "":new DateTime(entity.getEffectiveDate()).toString("yyyy-MM"));
enterpriseAccountSetOrgDto.getEffectiveDate() == null ? "" : new DateTime(entity.getEffectiveDate()).toString("yyyy-MM"));
enterpriseAccountSetOrgDto.setExpiredDateStr(
enterpriseAccountSetOrgDto.getExpiredDate()==null ? "":new DateTime(entity.getExpiredDate()).toString("yyyy-MM"));
enterpriseAccountSetOrgDto.getExpiredDate() == null ? "" : new DateTime(entity.getExpiredDate()).toString("yyyy-MM"));
enterpriseAccountSetOrgDto.setEnterpriseAccountSetName("");
enterpriseAccountSetOrgDto.setOrganizationName(
entity.getOrganization() == null ? "" : entity.getOrganization().getName());
......@@ -108,11 +110,9 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
}
/* (non-Javadoc)
* @see pwc.taxtech.atms.service.EnterpriseAccountService#updateEnterpriseAccountSet(pwc.taxtech.atms.service.dto.EnterpriseAccountSetDto)
*/
@Override
@Transactional
public OperationResultDto<?> updateEnterpriseAccountSet(EnterpriseAccountSetDto enterpriseAccountSetDto) {
......@@ -124,9 +124,9 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
boolean isChangeEnterpriseAccountSetCode = false;
//name change
if(!entity.getName().equals(enterpriseAccountSetDto.getName())) {
if (!entity.getName().equals(enterpriseAccountSetDto.getName())) {
OperationResultDto<?> validate = enterpriseAccountSetNameValidate(enterpriseAccountSetDto);
if(!validate.getResult()) {
if (!validate.getResult()) {
return validate;
}
updateToEntity.setName(enterpriseAccountSetDto.getName());
......@@ -134,9 +134,9 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
}
//code change
if(!entity.getCode().equals(enterpriseAccountSetDto.getCode())) {
if (!entity.getCode().equals(enterpriseAccountSetDto.getCode())) {
OperationResultDto<?> validate = enterpriseAccountSetCodeValidate(enterpriseAccountSetDto);
if(!validate.getResult()) {
if (!validate.getResult()) {
return validate;
}
updateToEntity.setCode(enterpriseAccountSetDto.getCode());
......@@ -147,7 +147,7 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
enterpriseAccountSetMapper.updateByPrimaryKeySelective(updateToEntity);
//add operation log
if(isChangeEnterpriseAccountSetName || isChangeEnterpriseAccountSetCode) {
if (isChangeEnterpriseAccountSetName || isChangeEnterpriseAccountSetCode) {
UpdateLogParams updateLogParams = new UpdateLogParams();
updateLogParams.setOperationUser(authUserHelper.getCurrentAuditor().get());
......@@ -169,12 +169,11 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
/* (non-Javadoc)
* @see pwc.taxtech.atms.service.EnterpriseAccountService#enterpriseAccountSetNameValidate(pwc.taxtech.atms.service.dto.EnterpriseAccountSetDto)
*/
@Override
public OperationResultDto<?> enterpriseAccountSetNameValidate(EnterpriseAccountSetDto enterpriseAccountSetDto) {
EnterpriseAccountSetExample example = new EnterpriseAccountSetExample();
EnterpriseAccountSetExample.Criteria criteria = example.createCriteria();
if(enterpriseAccountSetDto.getId()!=null) {
if (enterpriseAccountSetDto.getId() != null) {
criteria.andIdNotEqualTo(enterpriseAccountSetDto.getId());
}
criteria.andNameEqualTo(enterpriseAccountSetDto.getName());
......@@ -189,12 +188,11 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
/* (non-Javadoc)
* @see pwc.taxtech.atms.service.EnterpriseAccountService#enterpriseAccountSetCodeValidate(pwc.taxtech.atms.service.dto.EnterpriseAccountSetDto)
*/
@Override
public OperationResultDto<?> enterpriseAccountSetCodeValidate(EnterpriseAccountSetDto enterpriseAccountSetDto) {
EnterpriseAccountSetExample example = new EnterpriseAccountSetExample();
EnterpriseAccountSetExample.Criteria criteria = example.createCriteria();
if(enterpriseAccountSetDto.getId()!=null) {
if (enterpriseAccountSetDto.getId() != null) {
criteria.andIdNotEqualTo(enterpriseAccountSetDto.getId());
}
criteria.andCodeEqualTo(enterpriseAccountSetDto.getCode());
......@@ -210,25 +208,24 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
/* (non-Javadoc)
* @see pwc.taxtech.atms.service.EnterpriseAccountService#enterpriseAccountSetOrgValidate(pwc.taxtech.atms.service.dto.EnterpriseAccountSetDto)
*/
@Override
public OperationResultDto<?> enterpriseAccountSetOrgValidate(EnterpriseAccountSetDto enterpriseAccountSetDto) {
List<EnterpriseAccountSetOrgDto> enterpriseAccountSetOrgDtoList = enterpriseAccountSetDto.getEnterpriseAccountSetOrgList();
if (enterpriseAccountSetOrgDtoList == null ) {
if (enterpriseAccountSetOrgDtoList == null) {
enterpriseAccountSetOrgDtoList = new ArrayList<>();
}
//effective date > expire date
if(enterpriseAccountSetOrgDtoList.stream()
.anyMatch(sa -> sa.getEffectiveDate()!=null && sa.getExpiredDate()!=null
&& sa.getEffectiveDate().compareTo(sa.getExpiredDate())>0)) {
if (enterpriseAccountSetOrgDtoList.stream()
.anyMatch(sa -> sa.getEffectiveDate() != null && sa.getExpiredDate() != null
&& sa.getEffectiveDate().compareTo(sa.getExpiredDate()) > 0)) {
return new OperationResultDto<>(false, EnterpriseAccountSetOrgMessage.EffectiveDateAreaProblem);
}
//set org name
for(EnterpriseAccountSetOrgDto enterpriseAccountSetOrgDto: enterpriseAccountSetOrgDtoList) {
for (EnterpriseAccountSetOrgDto enterpriseAccountSetOrgDto : enterpriseAccountSetOrgDtoList) {
Organization organization = organizationMapper.selectByPrimaryKey(enterpriseAccountSetOrgDto.getOrganizationId());
if(organization!=null) {
if (organization != null) {
enterpriseAccountSetOrgDto.setOrganizationName(organization.getName());
}
}
......@@ -239,7 +236,7 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
.collect(Collectors.groupingBy(sa -> sa.getOrganizationId(), Collectors.counting()));
List<String> enterpriseAccountSetOrgIdInDtoList = new ArrayList<>();
enterpriseAccountSetOrgIdInDtoList = enterpriseAccountSetOrgDtoList.stream()
.filter(sa -> sa.getId()!=null)
.filter(sa -> sa.getId() != null)
.map(sa -> sa.getId()).collect(Collectors.toList());
......@@ -250,11 +247,11 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
EnterpriseAccountSetOrgExample example = new EnterpriseAccountSetOrgExample();
Criteria criteria = example.createCriteria();
criteria.andOrganizationIdEqualTo(organiztionCount.getKey());
if(!enterpriseAccountSetOrgIdInDtoList.isEmpty()) {
if (!enterpriseAccountSetOrgIdInDtoList.isEmpty()) {
criteria.andIdNotIn(enterpriseAccountSetOrgIdInDtoList);
}
List<EnterpriseAccountSetOrg> organiztionAccountSetInDBList = enterpriseAccountSetOrgMapper.selectByExample(example);
if(organiztionAccountSetInDBList!=null && !organiztionAccountSetInDBList.isEmpty()) {
if (organiztionAccountSetInDBList != null && !organiztionAccountSetInDBList.isEmpty()) {
organiztionAccountSetInDBList.stream().forEach(enterpriseAccountSetOrg -> {
EnterpriseAccountSetOrgDto enterpriseAccountSetOrgDto = new EnterpriseAccountSetOrgDto();
CommonUtils.copyProperties(enterpriseAccountSetOrg, enterpriseAccountSetOrgDto);
......@@ -263,7 +260,7 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
});
}
//同一个机构下的账套的时间段,是不能重叠的
if(CommonUtils.isOrganizationDateTimeOverlap(organiztionAccountSetList)) {
if (CommonUtils.isOrganizationDateTimeOverlap(organiztionAccountSetList)) {
List<EnterpriseAccountSetOrgDto> overlapList = organiztionAccountSetList.stream()
.filter(sa -> !sa.getOverlapList().isEmpty()).collect(Collectors.toList());
return new OperationResultDto<>(false, EnterpriseAccountSetOrgMessage.EnterpriseAccountSetOrgDateTimeOverlap, overlapList);
......@@ -279,41 +276,38 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
}
/*
* 1、判断传入的数据是否有时间段重叠
2、判断传入的数据与现有数据库中的数据,是否有时间段的重叠
* (non-Javadoc)
* @see pwc.taxtech.atms.service.EnterpriseAccountService#addEnterpriseAccountSetOrg(pwc.taxtech.atms.service.dto.EnterpriseAccountSetDto)
*/
@Override
@Transactional
public OperationResultDto<?> addEnterpriseAccountSetOrg(EnterpriseAccountSetDto enterpriseAccountSetDto) {
List<EnterpriseAccountSetOrgDto> enterpriseAccountSetOrgDtoList = enterpriseAccountSetDto.getEnterpriseAccountSetOrgList();
if(enterpriseAccountSetOrgDtoList==null || enterpriseAccountSetOrgDtoList.isEmpty()) {
if (enterpriseAccountSetOrgDtoList == null || enterpriseAccountSetOrgDtoList.isEmpty()) {
return OperationResultDto.success();
}
enterpriseAccountSetOrgDtoList.stream().forEach(sa -> {
if(sa.getEffectiveDateStr()!=null && !"".equals(sa.getEffectiveDateStr())) {
if (sa.getEffectiveDateStr() != null && !"".equals(sa.getEffectiveDateStr())) {
sa.setEffectiveDate(
DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(sa.getEffectiveDateStr()+"-01").toDate());
DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(sa.getEffectiveDateStr() + "-01").toDate());
}
if(sa.getExpiredDateStr()!=null && !"".equals(sa.getExpiredDateStr())) {
sa.setExpiredDate(DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(sa.getExpiredDateStr()+"-01")
if (sa.getExpiredDateStr() != null && !"".equals(sa.getExpiredDateStr())) {
sa.setExpiredDate(DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(sa.getExpiredDateStr() + "-01")
.plusMonths(1).minusDays(1).toDate());
}
});
OperationResultDto<?> checkResult = enterpriseAccountSetOrgValidate(enterpriseAccountSetDto);
if(!checkResult.getResult()) {
if (!checkResult.getResult()) {
return checkResult;
}
if(!enterpriseAccountSetOrgDtoList.isEmpty()) {
for(EnterpriseAccountSetOrgDto setOrgDto: enterpriseAccountSetOrgDtoList) {
if (!enterpriseAccountSetOrgDtoList.isEmpty()) {
for (EnterpriseAccountSetOrgDto setOrgDto : enterpriseAccountSetOrgDtoList) {
EnterpriseAccountSetOrg setOrg = new EnterpriseAccountSetOrg();
CommonUtils.copyProperties(setOrgDto, setOrg);
setOrg.setId(CommonUtils.getUUID());
......@@ -324,7 +318,7 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
//operational log
List<UpdateLogParams> updateLogParamsList = new ArrayList<>();
for(EnterpriseAccountSetOrgDto enterpriseAccountSetOrgDto : enterpriseAccountSetOrgDtoList) {
for (EnterpriseAccountSetOrgDto enterpriseAccountSetOrgDto : enterpriseAccountSetOrgDtoList) {
UpdateLogParams updateLogParams = new UpdateLogParams();
updateLogParams.setOperationUser(authUserHelper.getCurrentAuditor().get());
updateLogParams.setUpdateState("");
......@@ -344,20 +338,18 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
}
/* (non-Javadoc)
* @see pwc.taxtech.atms.service.EnterpriseAccountService#updateEnterpriseAccountSetOrg(pwc.taxtech.atms.service.dto.EnterpriseAccountSetOrgDto)
*/
@Override
@Transactional
public OperationResultDto<?> updateEnterpriseAccountSetOrg(EnterpriseAccountSetOrgDto enterpriseAccountSetOrgDto) {
if(enterpriseAccountSetOrgDto.getEffectiveDateStr()!=null && !"".equals(enterpriseAccountSetOrgDto.getEffectiveDateStr())) {
if (enterpriseAccountSetOrgDto.getEffectiveDateStr() != null && !"".equals(enterpriseAccountSetOrgDto.getEffectiveDateStr())) {
enterpriseAccountSetOrgDto.setEffectiveDate(
DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(enterpriseAccountSetOrgDto.getEffectiveDateStr()+"-01").toDate());
DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(enterpriseAccountSetOrgDto.getEffectiveDateStr() + "-01").toDate());
}
if(enterpriseAccountSetOrgDto.getExpiredDateStr()!=null && !"".equals(enterpriseAccountSetOrgDto.getExpiredDateStr())) {
enterpriseAccountSetOrgDto.setExpiredDate(DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(enterpriseAccountSetOrgDto.getExpiredDateStr()+"-01")
if (enterpriseAccountSetOrgDto.getExpiredDateStr() != null && !"".equals(enterpriseAccountSetOrgDto.getExpiredDateStr())) {
enterpriseAccountSetOrgDto.setExpiredDate(DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(enterpriseAccountSetOrgDto.getExpiredDateStr() + "-01")
.plusMonths(1).minusDays(1).toDate());
}
EnterpriseAccountSetDto enterpriseAccountSetDto = new EnterpriseAccountSetDto();
......@@ -368,12 +360,12 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
//validate enterpriseAccountSetOrg
OperationResultDto<?> checkResult = enterpriseAccountSetOrgValidate(enterpriseAccountSetDto);
if(!checkResult.getResult()) {
if (!checkResult.getResult()) {
return checkResult;
}
EnterpriseAccountSetOrg originalEntity = enterpriseAccountSetOrgMapper.selectByPrimaryKey(enterpriseAccountSetOrgDto.getId());
if(originalEntity==null) {
if (originalEntity == null) {
return new OperationResultDto<>(false, EnterpriseAccountSetOrgMessage.NoOrgSetOrOrgExist);
}
......@@ -392,14 +384,13 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
updateLogParams.setOperateLogType(OperateLogType.OperationLogEnterPrise.value());
updateLogParams.setComment("");
updateLogParams.setOperationAction(OperationAction.UpdateRelevantOrg.value());
if(originalEntity.getOrganizationId().equals(updateEntity.getOrganizationId())) {
updateLogParams.setUpdateState(enterpriseAccountSetOrgDto.getEffectiveDateStr()+","+enterpriseAccountSetOrgDto.getExpiredDateStr());
if (originalEntity.getOrganizationId().equals(updateEntity.getOrganizationId())) {
updateLogParams.setUpdateState(enterpriseAccountSetOrgDto.getEffectiveDateStr() + "," + enterpriseAccountSetOrgDto.getExpiredDateStr());
updateLogParams.setOriginalState(getEnterpriseAccountSetOrgTimeLog(originalEntity));
updateLogParams.setOperationContent(enterpriseAccountSetOrgDto.getOrganizationName());
}
else {
} else {
Organization originalOrganization = organizationMapper.selectByPrimaryKey(originalEntity.getOrganizationId());
String originalOrganizationName = originalOrganization == null ? "": originalOrganization.getName();
String originalOrganizationName = originalOrganization == null ? "" : originalOrganization.getName();
updateLogParams.setUpdateState(enterpriseAccountSetOrgDto.getOrganizationName() + ":"
+ enterpriseAccountSetOrgDto.getEffectiveDateStr() + "," + enterpriseAccountSetOrgDto.getExpiredDateStr());
updateLogParams.setOriginalState(originalOrganizationName + ":" + getEnterpriseAccountSetOrgTimeLog(originalEntity));
......@@ -413,12 +404,11 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
/* (non-Javadoc)
* @see pwc.taxtech.atms.service.EnterpriseAccountService#deleteEnterpriseAccountSetOrg(pwc.taxtech.atms.service.dto.EnterpriseAccountSetDto)
*/
@Override
@Transactional
public OperationResultDto<?> deleteEnterpriseAccountSetOrg(EnterpriseAccountSetDto enterpriseAccountSetDto) {
List<EnterpriseAccountSetOrgDto> enterpriseAccountSetOrgDtoList = enterpriseAccountSetDto.getEnterpriseAccountSetOrgList();
if(enterpriseAccountSetOrgDtoList == null) {
if (enterpriseAccountSetOrgDtoList == null) {
return OperationResultDto.success();
}
......@@ -432,7 +422,7 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
enterpriseAccountSetDto.setName(enterpriseAccountSet.getName());
List<UpdateLogParams> updateLogParamsList = new ArrayList<>();
for(EnterpriseAccountSetOrgDto enterpriseAccountSetOrgDto : enterpriseAccountSetOrgDtoList) {
for (EnterpriseAccountSetOrgDto enterpriseAccountSetOrgDto : enterpriseAccountSetOrgDtoList) {
UpdateLogParams updateLogParams = new UpdateLogParams();
updateLogParams.setOperationUser(authUserHelper.getCurrentAuditor().get());
updateLogParams.setUpdateState("");
......@@ -488,16 +478,15 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
/**
* Populate a string in the format of effectiveDateStr,expiredDateStr
*
* @param setOrg
* @return String
*/
private String getEnterpriseAccountSetOrgTimeLog(EnterpriseAccountSetOrg setOrg)
{
private String getEnterpriseAccountSetOrgTimeLog(EnterpriseAccountSetOrg setOrg) {
String effectiveDateStr = setOrg.getEffectiveDate() == null ? "" : new DateTime(setOrg.getEffectiveDate()).toString("yyyy-MM");
String expiredDateStr = setOrg.getExpiredDate() == null ? "" : new DateTime(setOrg.getExpiredDate()).toString("yyyy-MM");
return effectiveDateStr + "," + expiredDateStr;
}
}
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