Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
3abb818f
Commit
3abb818f
authored
Dec 03, 2021
by
季圣华
Browse files
优化供应商和客户的校验逻辑
parent
f24733fd
Changes
4
Hide whitespace changes
Inline
Side-by-side
jshERP-boot/src/main/java/com/jsh/erp/controller/SupplierController.java
View file @
3abb818f
...
...
@@ -55,6 +55,22 @@ public class SupplierController {
@Resource
private
UserService
userService
;
@GetMapping
(
value
=
"/checkIsNameAndTypeExist"
)
@ApiOperation
(
value
=
"检查名称和类型是否存在"
)
public
String
checkIsNameAndTypeExist
(
@RequestParam
Long
id
,
@RequestParam
(
value
=
"name"
)
String
name
,
@RequestParam
(
value
=
"type"
)
String
type
,
HttpServletRequest
request
)
throws
Exception
{
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<>();
int
exist
=
supplierService
.
checkIsNameAndTypeExist
(
id
,
name
,
type
);
if
(
exist
>
0
)
{
objectMap
.
put
(
"status"
,
true
);
}
else
{
objectMap
.
put
(
"status"
,
false
);
}
return
returnJson
(
objectMap
,
ErpInfo
.
OK
.
name
,
ErpInfo
.
OK
.
code
);
}
/**
* 查找客户信息-下拉框
* @param request
...
...
@@ -135,7 +151,7 @@ public class SupplierController {
for
(
Supplier
supplier
:
supplierList
)
{
JSONObject
item
=
new
JSONObject
();
item
.
put
(
"id"
,
supplier
.
getId
());
item
.
put
(
"supplier"
,
supplier
.
getSupplier
());
//供应商名称
item
.
put
(
"supplier"
,
supplier
.
getSupplier
()
+
"[供应商]"
);
//供应商名称
dataArray
.
add
(
item
);
}
}
...
...
@@ -151,7 +167,7 @@ public class SupplierController {
Boolean
flag
=
ubValue
.
contains
(
"["
+
supplier
.
getId
().
toString
()
+
"]"
);
if
(!
customerFlag
||
flag
)
{
item
.
put
(
"id"
,
supplier
.
getId
());
item
.
put
(
"supplier"
,
supplier
.
getSupplier
());
//客户名称
item
.
put
(
"supplier"
,
supplier
.
getSupplier
()
+
"[客户]"
);
//客户名称
dataArray
.
add
(
item
);
}
}
...
...
jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/SupplierMapperEx.java
View file @
3abb818f
...
...
@@ -31,6 +31,7 @@ public interface SupplierMapperEx {
int
batchDeleteSupplierByIds
(
@Param
(
"updateTime"
)
Date
updateTime
,
@Param
(
"updater"
)
Long
updater
,
@Param
(
"ids"
)
String
ids
[]);
Supplier
getSupplierByName
(
@Param
(
"supplier"
)
String
supplier
);
Supplier
getSupplierByNameAndType
(
@Param
(
"supplier"
)
String
supplier
,
@Param
(
"type"
)
String
type
);
}
\ No newline at end of file
jshERP-boot/src/main/java/com/jsh/erp/service/supplier/SupplierService.java
View file @
3abb818f
...
...
@@ -153,7 +153,7 @@ public class SupplierService {
//新增客户时给当前用户自动授权
if
(
"客户"
.
equals
(
supplier
.
getType
()))
{
Long
userId
=
userService
.
getUserId
(
request
);
Supplier
sInfo
=
supplierMapperEx
.
getSupplierByName
(
supplier
.
getSupplier
());
Supplier
sInfo
=
supplierMapperEx
.
getSupplierByName
AndType
(
supplier
.
getSupplier
()
,
supplier
.
getType
()
);
String
ubKey
=
"["
+
sInfo
.
getId
()
+
"]"
;
List
<
UserBusiness
>
ubList
=
userBusinessService
.
getBasicData
(
userId
.
toString
(),
"UserCustomer"
);
if
(
ubList
==
null
||
ubList
.
size
()
==
0
)
{
...
...
@@ -271,6 +271,19 @@ public class SupplierService {
return
list
==
null
?
0
:
list
.
size
();
}
public
int
checkIsNameAndTypeExist
(
Long
id
,
String
name
,
String
type
)
throws
Exception
{
SupplierExample
example
=
new
SupplierExample
();
example
.
createCriteria
().
andIdNotEqualTo
(
id
).
andSupplierEqualTo
(
name
).
andTypeEqualTo
(
type
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
List
<
Supplier
>
list
=
null
;
try
{
list
=
supplierMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
==
null
?
0
:
list
.
size
();
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateAdvanceIn
(
Long
supplierId
,
BigDecimal
advanceIn
)
throws
Exception
{
Supplier
supplier
=
null
;
...
...
jshERP-boot/src/main/resources/mapper_xml/SupplierMapperEx.xml
View file @
3abb818f
...
...
@@ -83,9 +83,9 @@
)
</update>
<select
id=
"getSupplierByName"
resultType=
"com.jsh.erp.datasource.entities.Supplier"
>
<select
id=
"getSupplierByName
AndType
"
resultType=
"com.jsh.erp.datasource.entities.Supplier"
>
select *
from jsh_supplier
where supplier = #{supplier}
where supplier = #{supplier}
and type = #{type}
</select>
</mapper>
\ No newline at end of file
Write
Preview
Supports
Markdown
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