Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
traffic-front
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangxiaoming
traffic-front
Commits
2af32692
Commit
2af32692
authored
Oct 09, 2018
by
neo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DEL] delete enterprise account set service interface
parent
e8d180c5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
270 additions
and
353 deletions
+270
-353
EnterpriseAccountManagerController.java
...h/atms/controller/EnterpriseAccountManagerController.java
+158
-147
EnterpriseAccountSetService.java
...pwc/taxtech/atms/service/EnterpriseAccountSetService.java
+0
-82
EnterpriseAccountServiceImpl.java
...xtech/atms/service/impl/EnterpriseAccountServiceImpl.java
+1
-2
EnterpriseAccountSetServiceImpl.java
...ch/atms/service/impl/EnterpriseAccountSetServiceImpl.java
+111
-122
No files found.
atms-api/src/main/java/pwc/taxtech/atms/controller/EnterpriseAccountManagerController.java
View file @
2af32692
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,159 +17,174 @@ 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
;
@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
()
{
return
enterpriseAccountSetService
.
getEnterpriseAccountSetList
();
@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
()
{
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
)
{
@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
)
{
return
enterpriseAccountSetService
.
getEnterpriseAccountSet
(
id
);
}
@SuppressWarnings
(
"rawtypes"
)
@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"
)
@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
);
return
enterpriseAccountSetService
.
enterpriseAccountSetNameValidate
(
enterpriseAccountSetDto
);
return
enterpriseAccountSetService
.
enterpriseAccountSetNameValidate
(
enterpriseAccountSetDto
);
}
@SuppressWarnings
(
"rawtypes"
)
@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
);
return
enterpriseAccountSetService
.
enterpriseAccountSetCodeValidate
(
enterpriseAccountSetDto
);
}
@SuppressWarnings
(
"rawtypes"
)
@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
)
{
return
enterpriseAccountSetService
.
enterpriseAccountSetOrgValidate
(
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"
)
@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"
)
@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"
)
@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
)
@ApiOperation
(
value
=
"Download Enterprise account template"
)
@RequestMapping
(
value
=
{
"/downEntepriseAccountTemplate"
},
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
public
void
downEntepriseAccountTemplate
(
HttpServletResponse
response
)
{
String
filePath
;
File
templateFile
=
null
;
InputStream
inputStream
=
null
;
try
{
filePath
=
EnterpriseAccountManagerController
.
class
.
getClassLoader
().
getResource
(
""
).
toURI
().
getPath
();
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
.
setContentType
(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
);
FileCopyUtils
.
copy
(
inputStream
,
response
.
getOutputStream
());
}
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
)
{
logger
.
error
(
"Error downloading template file "
+
EnterpriseAccountConstant
.
EntepriseAccountFileName
+
".xlsx"
,
e
);
throw
new
ApplicationException
(
"Error downloading template file "
+
EnterpriseAccountConstant
.
EntepriseAccountFileName
+
".xlsx"
,
e
);
}
finally
{
try
{
templateFile
=
null
;
if
(
inputStream
!=
null
)
{
inputStream
.
close
();
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"Error closing inputstream. "
,
e
);
}
finally
{
inputStream
=
null
;
}
}
String
filePath
;
File
templateFile
=
null
;
InputStream
inputStream
=
null
;
try
{
filePath
=
EnterpriseAccountManagerController
.
class
.
getClassLoader
().
getResource
(
""
).
toURI
().
getPath
();
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
.
setContentType
(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
);
FileCopyUtils
.
copy
(
inputStream
,
response
.
getOutputStream
());
}
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
)
{
logger
.
error
(
"Error downloading template file "
+
EnterpriseAccountConstant
.
EntepriseAccountFileName
+
".xlsx"
,
e
);
throw
new
ApplicationException
(
"Error downloading template file "
+
EnterpriseAccountConstant
.
EntepriseAccountFileName
+
".xlsx"
,
e
);
}
finally
{
try
{
templateFile
=
null
;
if
(
inputStream
!=
null
)
{
inputStream
.
close
();
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"Error closing inputstream. "
,
e
);
}
finally
{
inputStream
=
null
;
}
}
}
@SuppressWarnings
(
"rawtypes"
)
@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
,
@RequestParam
(
value
=
"file"
,
required
=
false
)
CommonsMultipartFile
inputFile
)
{
if
(
inputFile
==
null
||
inputFile
.
getSize
()
<=
0
)
{
return
new
OperationResultDto
<>(
false
,
ErrorMessage
.
NoFile
);
}
logger
.
debug
(
"file name: "
+
inputFile
.
getOriginalFilename
());
@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
)
{
return
new
OperationResultDto
<>(
false
,
ErrorMessage
.
NoFile
);
}
logger
.
debug
(
"file name: "
+
inputFile
.
getOriginalFilename
());
InputStream
inputStream
=
null
;
try
{
inputStream
=
inputFile
.
getInputStream
();
inputStream
=
inputFile
.
getInputStream
();
}
catch
(
IOException
e
)
{
throw
Lang
.
wrapThrow
(
e
);
}
//save file
String
filePath
=
FileUtils
.
getTempDirectory
().
getAbsolutePath
()
+
File
.
separator
+
"EnterpriseAccount"
+
File
.
separator
+
CommonUtils
.
getUUID
()
+
"_"
+
inputFile
.
getOriginalFilename
();
...
...
@@ -187,87 +193,92 @@ public class EnterpriseAccountManagerController {
if
(
saveResult
.
getResult
()
!=
null
&&
!
saveResult
.
getResult
())
{
return
saveResult
;
}
//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
());
enterpriseAccountSetDto
.
setName
(
uploadForm
.
getName
());
enterpriseAccountSetDto
.
setIsImportAppend
(
Boolean
.
valueOf
(
uploadForm
.
getIsImportAppend
()));
enterpriseAccountService
.
repeatImportEnterpriseAccountSet
(
enterpriseAccountSetDto
,
validateResult
.
getData
());
}
return
OperationResultDto
.
success
();
return
OperationResultDto
.
success
();
}
@ApiOperation
(
value
=
"Gets the list by enterprise account set identifier."
)
@RequestMapping
(
value
=
{
"/getListByEnterpriseAccountSetID"
},
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
@ApiOperation
(
value
=
"Gets the list by enterprise account set identifier."
)
@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
)
{
@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
)
{
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
)
{
@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
)
{
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
)
{
@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
)
{
return
enterpriseAccountService
.
updateEnterpriseAccount
(
enterpriseAccountDto
);
}
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"rawtypes"
)
@ApiOperation
(
value
=
"一键删除重复企业科目"
)
@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
=
{
"/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
)
{
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
);
}
...
...
atms-api/src/main/java/pwc/taxtech/atms/service/EnterpriseAccountSetService.java
deleted
100644 → 0
View file @
e8d180c5
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
);
}
atms-api/src/main/java/pwc/taxtech/atms/service/impl/EnterpriseAccountServiceImpl.java
View file @
2af32692
...
...
@@ -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
EnterpriseAccountSetService
Impl
enterpriseAccountSetService
;
@Autowired
private
FileService
fileService
;
@Autowired
...
...
atms-api/src/main/java/pwc/taxtech/atms/service/impl/EnterpriseAccountSetServiceImpl.java
View file @
2af32692
...
...
@@ -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,24 +33,28 @@ 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
OperationLogService
operationLogService
;
@Autowired
private
AuthUserHelper
authUserHelper
;
@Autowired
private
EnterpriseAccountSetMapper
enterpriseAccountSetMapper
;
@Autowired
private
EnterpriseAccountSetOrgMapper
enterpriseAccountSetOrgMapper
;
@Autowired
private
OrganizationMapper
organizationMapper
;
@Autowired
private
OperationLogService
operationLogService
;
@Autowired
private
AuthUserHelper
authUserHelper
;
/*
* (non-Javadoc)
*
*
* @see pwc.taxtech.atms.service.EnterpriseAccountSetService#
* getEnterpriseAccountSetList()
*/
@Override
public
List
<
EnterpriseAccountSetDto
>
getEnterpriseAccountSetList
()
{
EnterpriseAccountSetExample
example
=
new
EnterpriseAccountSetExample
();
...
...
@@ -62,12 +65,11 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
/*
* (non-Javadoc)
*
*
* @see
* 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
());
...
...
@@ -107,48 +109,46 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
return
enterpriseAccountSetDto
;
}
/* (non-Javadoc)
* @see pwc.taxtech.atms.service.EnterpriseAccountService#updateEnterpriseAccountSet(pwc.taxtech.atms.service.dto.EnterpriseAccountSetDto)
*/
@Override
@Transactional
public
OperationResultDto
<?>
updateEnterpriseAccountSet
(
EnterpriseAccountSetDto
enterpriseAccountSetDto
)
{
EnterpriseAccountSet
entity
=
enterpriseAccountSetMapper
.
selectByPrimaryKey
(
enterpriseAccountSetDto
.
getId
());
EnterpriseAccountSet
updateToEntity
=
new
EnterpriseAccountSet
();
CommonUtils
.
copyProperties
(
entity
,
updateToEntity
);
boolean
isChangeEnterpriseAccountSetName
=
false
;
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
());
isChangeEnterpriseAccountSetName
=
true
;
}
//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
());
isChangeEnterpriseAccountSetCode
=
true
;
}
//update DB
enterpriseAccountSetMapper
.
updateByPrimaryKeySelective
(
updateToEntity
);
//add operation log
if
(
isChangeEnterpriseAccountSetName
||
isChangeEnterpriseAccountSetCode
)
{
if
(
isChangeEnterpriseAccountSetName
||
isChangeEnterpriseAccountSetCode
)
{
UpdateLogParams
updateLogParams
=
new
UpdateLogParams
();
updateLogParams
.
setOperationUser
(
authUserHelper
.
getCurrentAuditor
().
get
());
updateLogParams
.
setUpdateState
(
updateToEntity
);
...
...
@@ -159,90 +159,87 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
updateLogParams
.
setOperateLogType
(
OperateLogType
.
OperationLogEnterPrise
.
value
());
updateLogParams
.
setOperationAction
(
OperationAction
.
UpdateEnterpriseAccountSet
.
value
());
updateLogParams
.
setOperationObject
(
entity
.
getCode
());
operationLogService
.
updateDataAddLog
(
updateLogParams
);
}
return
new
OperationResultDto
<>(
true
);
}
/* (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
());
List
<
EnterpriseAccountSet
>
enterpriseAccountSetList
=
enterpriseAccountSetMapper
.
selectByExample
(
example
);
if
(
enterpriseAccountSetList
!=
null
&&
!
enterpriseAccountSetList
.
isEmpty
())
{
return
new
OperationResultDto
<>(
false
,
EnterpriseAccountSetMessage
.
EnterpriseAccountSetNameRepeat
);
}
return
new
OperationResultDto
<>(
true
);
}
/* (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
());
List
<
EnterpriseAccountSet
>
enterpriseAccountSetList
=
enterpriseAccountSetMapper
.
selectByExample
(
example
);
if
(
enterpriseAccountSetList
!=
null
&&
!
enterpriseAccountSetList
.
isEmpty
())
{
return
new
OperationResultDto
<>(
false
,
EnterpriseAccountSetMessage
.
EnterpriseAccountSetCodeRepeat
);
}
return
new
OperationResultDto
<>(
true
);
}
/* (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
());
}
}
//validate by each organization
//Map<organizationId, count>
Map
<
String
,
Long
>
countByOrganization
=
enterpriseAccountSetOrgDtoList
.
stream
()
.
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
());
for
(
Map
.
Entry
<
String
,
Long
>
organiztionCount
:
countByOrganization
.
entrySet
())
{
List
<
EnterpriseAccountSetOrgDto
>
organiztionAccountSetList
=
enterpriseAccountSetOrgDtoList
.
stream
()
.
filter
(
sa
->
sa
.
getOrganizationId
().
equals
(
organiztionCount
.
getKey
()))
...
...
@@ -250,70 +247,67 @@ 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
);
enterpriseAccountSetOrgDto
.
setOverlapList
(
new
ArrayList
<>());
organiztionAccountSetList
.
add
(
enterpriseAccountSetOrgDto
);
});
EnterpriseAccountSetOrgDto
enterpriseAccountSetOrgDto
=
new
EnterpriseAccountSetOrgDto
();
CommonUtils
.
copyProperties
(
enterpriseAccountSetOrg
,
enterpriseAccountSetOrgDto
);
enterpriseAccountSetOrgDto
.
setOverlapList
(
new
ArrayList
<>());
organiztionAccountSetList
.
add
(
enterpriseAccountSetOrgDto
);
});
}
//同一个机构下的账套的时间段,是不能重叠的
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
);
}
// 一年之内不能设置两个一样的账套,即:不能设置这种,账套A,2017年1月到3月,账套A,2017年4月到5月
if
(!
CommonUtils
.
validateOnlyOncePerYear
(
organiztionAccountSetList
))
{
return
new
OperationResultDto
<>(
false
,
EnterpriseAccountSetOrgMessage
.
EnterpriseAccountSetOrgOnlyOncePerYear
);
}
}
return
OperationResultDto
.
success
();
}
/*
* 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
());
...
...
@@ -321,10 +315,10 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
enterpriseAccountSetOrgMapper
.
insert
(
setOrg
);
}
}
//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
(
""
);
...
...
@@ -339,25 +333,23 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
updateLogParamsList
.
add
(
updateLogParams
);
}
operationLogService
.
addOrDeleteDataAddLog
(
updateLogParamsList
);
return
OperationResultDto
.
success
();
}
/* (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
();
...
...
@@ -365,25 +357,25 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
enterpriseAccountSetDto
.
setName
(
enterpriseAccountSetOrgDto
.
getEnterpriseAccountSetName
());
enterpriseAccountSetDto
.
setEnterpriseAccountSetOrgList
(
new
ArrayList
<>());
enterpriseAccountSetDto
.
getEnterpriseAccountSetOrgList
().
add
(
enterpriseAccountSetOrgDto
);
//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
);
}
EnterpriseAccountSetOrg
updateEntity
=
new
EnterpriseAccountSetOrg
();
CommonUtils
.
copyProperties
(
originalEntity
,
updateEntity
);
updateEntity
.
setOrganizationId
(
enterpriseAccountSetOrgDto
.
getOrganizationId
());
updateEntity
.
setEffectiveDate
(
enterpriseAccountSetOrgDto
.
getEffectiveDate
());
updateEntity
.
setExpiredDate
(
enterpriseAccountSetOrgDto
.
getExpiredDate
());
enterpriseAccountSetOrgMapper
.
updateByPrimaryKey
(
updateEntity
);
//operational log
UpdateLogParams
updateLogParams
=
new
UpdateLogParams
();
updateLogParams
.
setOperationUser
(
authUserHelper
.
getCurrentAuditor
().
get
());
...
...
@@ -392,47 +384,45 @@ 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
();
updateLogParams
.
setUpdateState
(
enterpriseAccountSetOrgDto
.
getOrganizationName
()
+
":"
String
originalOrganizationName
=
originalOrganization
==
null
?
""
:
originalOrganization
.
getName
();
updateLogParams
.
setUpdateState
(
enterpriseAccountSetOrgDto
.
getOrganizationName
()
+
":"
+
enterpriseAccountSetOrgDto
.
getEffectiveDateStr
()
+
","
+
enterpriseAccountSetOrgDto
.
getExpiredDateStr
());
updateLogParams
.
setOriginalState
(
originalOrganizationName
+
":"
+
getEnterpriseAccountSetOrgTimeLog
(
originalEntity
));
updateLogParams
.
setOperationContent
(
originalOrganizationName
);
}
operationLogService
.
addOrDeleteDataAddLog
(
updateLogParams
);
return
OperationResultDto
.
success
();
}
/* (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
();
}
List
<
String
>
enterpriseAccountSetOrgIdList
=
enterpriseAccountSetOrgDtoList
.
stream
()
.
map
(
sa
->
sa
.
getId
()).
collect
(
Collectors
.
toList
());
EnterpriseAccountSetOrgExample
example
=
new
EnterpriseAccountSetOrgExample
();
example
.
createCriteria
().
andIdIn
(
enterpriseAccountSetOrgIdList
);
enterpriseAccountSetOrgMapper
.
deleteByExample
(
example
);
EnterpriseAccountSet
enterpriseAccountSet
=
enterpriseAccountSetMapper
.
selectByPrimaryKey
(
enterpriseAccountSetDto
.
getId
());
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
(
""
);
...
...
@@ -446,14 +436,14 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
updateLogParamsList
.
add
(
updateLogParams
);
}
operationLogService
.
addOrDeleteDataAddLog
(
updateLogParamsList
);
return
OperationResultDto
.
success
();
}
/**
* Populate EnterpriseAccountSetDto list from EnterpriseAccountSet entity list
*
*
* @param enterpriseAccountSetList
* @return
*/
...
...
@@ -472,7 +462,7 @@ public class EnterpriseAccountSetServiceImpl implements EnterpriseAccountSetServ
/**
* Populate EnterpriseAccountSetDto object from EnterpriseAccountSet entity
*
*
* @param enterpriseAccountSet
* @return
*/
...
...
@@ -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
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment