Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dakong-digital-management
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
耿迪迪
dakong-digital-management
Commits
9588dc98
Commit
9588dc98
authored
Aug 28, 2024
by
耿迪迪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
库存增扣逻辑优化
parent
7af1919d
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
57 additions
and
28 deletions
+57
-28
TProductStoreController.java
.../zehong/web/controller/track/TProductStoreController.java
+14
-3
SecurityConfig.java
...main/java/com/zehong/framework/config/SecurityConfig.java
+0
-1
TProductInspectDetailServiceImpl.java
.../service/impl/track/TProductInspectDetailServiceImpl.java
+10
-11
TProductStoreServiceImpl.java
...g/system/service/impl/track/TProductStoreServiceImpl.java
+25
-4
ITProductStoreService.java
...om/zehong/system/service/track/ITProductStoreService.java
+2
-1
AddDetail.vue
...b/src/views/track/execute/detail/components/AddDetail.vue
+0
-2
House.vue
...management-web/src/views/track/store/components/House.vue
+2
-2
index.vue
digital-management-web/src/views/track/store/index.vue
+4
-4
No files found.
digital-management-admin/src/main/java/com/zehong/web/controller/track/TProductStoreController.java
View file @
9588dc98
...
@@ -110,12 +110,23 @@ public class TProductStoreController extends BaseController
...
@@ -110,12 +110,23 @@ public class TProductStoreController extends BaseController
}
}
/**
/**
* 入库
信息
* 入库
* @param storeInfo
* @param storeInfo
入库信息
* @return
* @return
*/
*/
@PostMapping
(
"/inHouse"
)
@PostMapping
(
"/inHouse"
)
public
AjaxResult
inHouse
(
@RequestBody
List
<
HouseVo
>
storeInfo
){
public
AjaxResult
inHouse
(
@RequestBody
List
<
HouseVo
>
storeInfo
){
return
toAjax
(
tProductStoreService
.
inHouse
(
storeInfo
,
true
));
return
toAjax
(
tProductStoreService
.
computeStock
(
storeInfo
,
true
,
"add"
));
}
/**
* 出库
* @param storeInfo 出库信息
* @return
*/
@PostMapping
(
"/outHouse"
)
public
AjaxResult
outHouse
(
@RequestBody
List
<
HouseVo
>
storeInfo
){
return
toAjax
(
tProductStoreService
.
computeStock
(
storeInfo
,
true
,
"subtract"
));
}
}
}
}
digital-management-framework/src/main/java/com/zehong/framework/config/SecurityConfig.java
View file @
9588dc98
...
@@ -105,7 +105,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
...
@@ -105,7 +105,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
"/**/*.css"
,
"/**/*.css"
,
"/**/*.js"
"/**/*.js"
).
permitAll
()
).
permitAll
()
.
antMatchers
(
"/track/store/**"
).
permitAll
()
.
antMatchers
(
"/profile/**"
).
anonymous
()
.
antMatchers
(
"/profile/**"
).
anonymous
()
.
antMatchers
(
"/common/download**"
).
anonymous
()
.
antMatchers
(
"/common/download**"
).
anonymous
()
.
antMatchers
(
"/common/download/resource**"
).
anonymous
()
.
antMatchers
(
"/common/download/resource**"
).
anonymous
()
...
...
digital-management-system/src/main/java/com/zehong/system/service/impl/track/TProductInspectDetailServiceImpl.java
View file @
9588dc98
...
@@ -4,7 +4,6 @@ import com.zehong.common.exception.CustomException;
...
@@ -4,7 +4,6 @@ import com.zehong.common.exception.CustomException;
import
com.zehong.common.utils.DateUtils
;
import
com.zehong.common.utils.DateUtils
;
import
com.zehong.common.utils.SecurityUtils
;
import
com.zehong.common.utils.SecurityUtils
;
import
com.zehong.system.domain.track.TProductInspectDetail
;
import
com.zehong.system.domain.track.TProductInspectDetail
;
import
com.zehong.system.domain.track.TProductStore
;
import
com.zehong.system.domain.vo.HouseVo
;
import
com.zehong.system.domain.vo.HouseVo
;
import
com.zehong.system.mapper.TProductInspectDetailMapper
;
import
com.zehong.system.mapper.TProductInspectDetailMapper
;
import
com.zehong.system.service.track.ITProductInspectDetailService
;
import
com.zehong.system.service.track.ITProductInspectDetailService
;
...
@@ -104,7 +103,7 @@ public class TProductInspectDetailServiceImpl implements ITProductInspectDetailS
...
@@ -104,7 +103,7 @@ public class TProductInspectDetailServiceImpl implements ITProductInspectDetailS
storeInfo
.
add
(
house
);
storeInfo
.
add
(
house
);
}
}
}
}
if
(!
CollectionUtils
.
isEmpty
(
storeInfo
))
itProductStoreService
.
inHouse
(
storeInfo
,
false
);
if
(!
CollectionUtils
.
isEmpty
(
storeInfo
))
itProductStoreService
.
computeStock
(
storeInfo
,
false
,
"add"
);
return
tProductInspectDetailMapper
.
deleteTProductInspectDetailByIds
(
ids
);
return
tProductInspectDetailMapper
.
deleteTProductInspectDetailByIds
(
ids
);
}
}
...
@@ -161,15 +160,15 @@ public class TProductInspectDetailServiceImpl implements ITProductInspectDetailS
...
@@ -161,15 +160,15 @@ public class TProductInspectDetailServiceImpl implements ITProductInspectDetailS
*/
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
int
subtractStoreStock
(
List
<
TProductInspectDetail
>
productInspectDetailList
){
public
int
subtractStoreStock
(
List
<
TProductInspectDetail
>
productInspectDetailList
){
List
<
TProductInspectDetail
>
storeList
=
productInspectDetailList
.
stream
().
filter
(
item
->
2
==
item
.
getType
()).
collect
(
Collectors
.
toList
());
List
<
HouseVo
>
storeList
=
productInspectDetailList
.
stream
().
filter
(
item
->
2
==
item
.
getType
())
for
(
TProductInspectDetail
detail
:
storeList
)
{
.
map
(
item
->
{
TProductStore
store
=
itProductStoreService
.
selectTProductStoreById
(
detail
.
getTypeId
()
);
HouseVo
house
=
new
HouseVo
(
);
if
(
store
.
getTotal
().
compareTo
(
detail
.
getNumber
())
==
-
1
){
house
.
setId
(
item
.
getTypeId
());
throw
new
CustomException
(
store
.
getTitle
()
+
"库存不足"
);
house
.
setNum
(
item
.
getNumber
()
);
}
return
house
;
store
.
setTotal
(
store
.
getTotal
()
-
detail
.
getNumber
());
})
itProductStoreService
.
updateTProductStore
(
store
);
.
collect
(
Collectors
.
toList
()
);
}
itProductStoreService
.
computeStock
(
storeList
,
false
,
"subtract"
);
return
tProductInspectDetailMapper
.
batchAddDetailInfo
(
productInspectDetailList
);
return
tProductInspectDetailMapper
.
batchAddDetailInfo
(
productInspectDetailList
);
}
}
}
}
digital-management-system/src/main/java/com/zehong/system/service/impl/track/TProductStoreServiceImpl.java
View file @
9588dc98
package
com
.
zehong
.
system
.
service
.
impl
.
track
;
package
com
.
zehong
.
system
.
service
.
impl
.
track
;
import
com.zehong.common.exception.CustomException
;
import
com.zehong.common.utils.DateUtils
;
import
com.zehong.common.utils.DateUtils
;
import
com.zehong.common.utils.SecurityUtils
;
import
com.zehong.common.utils.SecurityUtils
;
import
com.zehong.system.domain.track.TProductInspectDetail
;
import
com.zehong.system.domain.track.TProductStore
;
import
com.zehong.system.domain.track.TProductStore
;
import
com.zehong.system.domain.track.TProductStoreLog
;
import
com.zehong.system.domain.track.TProductStoreLog
;
import
com.zehong.system.domain.vo.HouseVo
;
import
com.zehong.system.domain.vo.HouseVo
;
...
@@ -14,7 +14,6 @@ import org.springframework.stereotype.Service;
...
@@ -14,7 +14,6 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -115,12 +114,17 @@ public class TProductStoreServiceImpl implements ITProductStoreService
...
@@ -115,12 +114,17 @@ public class TProductStoreServiceImpl implements ITProductStoreService
* 配件批量入库
* 配件批量入库
* @param storeInfo 配件信息
* @param storeInfo 配件信息
* @param isAddLog 是否插入日志
* @param isAddLog 是否插入日志
* @param type 操作类型
* @return
* @return
*/
*/
@Override
@Override
public
int
inHouse
(
List
<
HouseVo
>
storeInfo
,
boolean
isAddLog
){
public
int
computeStock
(
List
<
HouseVo
>
storeInfo
,
boolean
isAddLog
,
String
type
){
synchronized
(
this
){
synchronized
(
this
){
addStoreStock
(
storeInfo
,
isAddLog
);
if
(
"add"
.
equals
(
type
)){
addStoreStock
(
storeInfo
,
isAddLog
);
}
else
{
subtractStoreStock
(
storeInfo
);
}
}
}
return
1
;
return
1
;
}
}
...
@@ -145,4 +149,21 @@ public class TProductStoreServiceImpl implements ITProductStoreService
...
@@ -145,4 +149,21 @@ public class TProductStoreServiceImpl implements ITProductStoreService
}
}
}
}
}
}
/**
* 扣出库存
* @param storeList
* @return
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
subtractStoreStock
(
List
<
HouseVo
>
storeList
){
for
(
HouseVo
storeInfo
:
storeList
){
TProductStore
store
=
tProductStoreMapper
.
selectTProductStoreById
(
storeInfo
.
getId
());
if
(
store
.
getTotal
().
compareTo
(
storeInfo
.
getNum
())
==
-
1
){
throw
new
CustomException
(
store
.
getTitle
()
+
"库存不足"
);
}
store
.
setTotal
(
store
.
getTotal
()
-
storeInfo
.
getNum
());
tProductStoreMapper
.
updateTProductStore
(
store
);
}
}
}
}
digital-management-system/src/main/java/com/zehong/system/service/track/ITProductStoreService.java
View file @
9588dc98
...
@@ -66,8 +66,9 @@ public interface ITProductStoreService
...
@@ -66,8 +66,9 @@ public interface ITProductStoreService
* 配件批量入库
* 配件批量入库
* @param storeInfo 配件信息
* @param storeInfo 配件信息
* @param isAddLog 是否记录日志
* @param isAddLog 是否记录日志
* @param type 操作类型
* @return
* @return
*/
*/
int
inHouse
(
List
<
HouseVo
>
storeInfo
,
boolean
isAddLog
);
int
computeStock
(
List
<
HouseVo
>
storeInfo
,
boolean
isAddLog
,
String
type
);
}
}
digital-management-web/src/views/track/execute/detail/components/AddDetail.vue
View file @
9588dc98
...
@@ -150,9 +150,7 @@
...
@@ -150,9 +150,7 @@
validateData
(){
validateData
(){
//检查信息是否完整
//检查信息是否完整
for
(
var
i
=
0
;
i
<
this
.
detailInfoList
.
length
;
i
++
){
for
(
var
i
=
0
;
i
<
this
.
detailInfoList
.
length
;
i
++
){
console
.
log
(
"============================="
,(
this
.
detailInfoList
[
i
].
typeId
&&
this
.
detailInfoList
[
i
].
type
))
if
(
!
(
this
.
detailInfoList
[
i
].
typeId
&&
this
.
detailInfoList
[
i
].
type
&&
this
.
detailInfoList
[
i
].
number
)
&&
2
==
this
.
detailInfoList
[
i
].
type
){
if
(
!
(
this
.
detailInfoList
[
i
].
typeId
&&
this
.
detailInfoList
[
i
].
type
&&
this
.
detailInfoList
[
i
].
number
)
&&
2
==
this
.
detailInfoList
[
i
].
type
){
console
.
log
(
"============================="
)
this
.
$message
.
error
(
"请检查信息是否填完整"
);
this
.
$message
.
error
(
"请检查信息是否填完整"
);
return
true
;
return
true
;
}
}
...
...
digital-management-web/src/views/track/store/components/House.vue
View file @
9588dc98
...
@@ -73,8 +73,8 @@
...
@@ -73,8 +73,8 @@
}
}
},
},
submitStore
(){
submitStore
(){
for
(
var
i
=
0
;
i
<
this
.
detailInfoList
.
length
;
i
++
){
for
(
var
i
=
0
;
i
<
this
.
inHouseStore
.
length
;
i
++
){
if
(
!
(
this
.
detailInfoList
[
i
].
id
&&
this
.
detailInfoList
[
i
].
num
)){
if
(
!
(
this
.
inHouseStore
[
i
].
id
&&
this
.
inHouseStore
[
i
].
num
)){
this
.
$message
.
error
(
"请检查信息是否填完整"
);
this
.
$message
.
error
(
"请检查信息是否填完整"
);
return
return
}
}
...
...
digital-management-web/src/views/track/store/index.vue
View file @
9588dc98
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
@
click=
"handleAdd"
@
click=
"handleAdd"
>
新增
</el-button>
>
新增
</el-button>
</el-col>
</el-col>
<el-col
:span=
"1.5"
>
<
!--
<
el-col
:span=
"1.5"
>
<el-button
<el-button
type=
"success"
type=
"success"
plain
plain
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
:disabled=
"single"
:disabled=
"single"
@
click=
"handleUpdate"
@
click=
"handleUpdate"
>
修改
</el-button>
>
修改
</el-button>
</el-col>
</el-col>
-->
<el-col
:span=
"1.5"
>
<el-col
:span=
"1.5"
>
<el-button
<el-button
type=
"danger"
type=
"danger"
...
@@ -112,12 +112,12 @@
...
@@ -112,12 +112,12 @@
icon=
"el-icon-document"
icon=
"el-icon-document"
@
click=
"handleDetail(scope.row)"
@
click=
"handleDetail(scope.row)"
>
详情
</el-button>
>
详情
</el-button>
<el-button
<
!--
<
el-button
size=
"mini"
size=
"mini"
type=
"text"
type=
"text"
icon=
"el-icon-edit"
icon=
"el-icon-edit"
@
click=
"handleUpdate(scope.row)"
@
click=
"handleUpdate(scope.row)"
>
修改
</el-button>
>
修改
</el-button>
-->
<el-button
<el-button
size=
"mini"
size=
"mini"
type=
"text"
type=
"text"
...
...
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