Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
E
erp-service
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
ximai
erp-service
Commits
35cee4a6
Commit
35cee4a6
authored
May 19, 2026
by
chicheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
录入入库单、领料单、销售出库单调整
parent
725d8fb7
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
168 additions
and
30 deletions
+168
-30
CoptoDao.java
...ain/java/com/topsunit/scanservice/ximai/dao/CoptoDao.java
+2
-0
InvmlCriteria.java
...ava/com/topsunit/scanservice/ximai/dto/InvmlCriteria.java
+6
-0
InvmlDto.java
...ain/java/com/topsunit/scanservice/ximai/dto/InvmlDto.java
+4
-0
MoctaDto.java
...ain/java/com/topsunit/scanservice/ximai/dto/MoctaDto.java
+6
-0
StockSaleOutDto.java
...a/com/topsunit/scanservice/ximai/dto/StockSaleOutDto.java
+25
-1
StockSaleOutParams.java
...om/topsunit/scanservice/ximai/dto/StockSaleOutParams.java
+2
-0
CopthService.java
.../com/topsunit/scanservice/ximai/service/CopthService.java
+9
-3
CoptoService.java
.../com/topsunit/scanservice/ximai/service/CoptoService.java
+37
-17
InvmcService.java
.../com/topsunit/scanservice/ximai/service/InvmcService.java
+46
-2
MoctaService.java
.../com/topsunit/scanservice/ximai/service/MoctaService.java
+31
-7
No files found.
erp-system/src/main/java/com/topsunit/scanservice/ximai/dao/CoptoDao.java
View file @
35cee4a6
...
...
@@ -24,4 +24,6 @@ public interface CoptoDao extends JpaRepository<Copto, CoptoId>, JpaSpecificatio
Optional
<
Copto
>
findFirstByTo001AndTo002AndTo007
(
String
t0001
,
String
t0002
,
String
t0007
);
Optional
<
Copto
>
findFirstByTo001AndTo002AndTo003
(
String
to001
,
String
to002
,
String
to003
);
}
erp-system/src/main/java/com/topsunit/scanservice/ximai/dto/InvmlCriteria.java
View file @
35cee4a6
...
...
@@ -23,4 +23,10 @@ public class InvmlCriteria {
@ApiModelProperty
(
"库存大于"
)
private
Integer
gtStock
;
@ApiModelProperty
(
"出货通知单号(扣减未确认占用)"
)
private
String
saleOutNo
;
@ApiModelProperty
(
"通知单序号(扣减未确认占用)"
)
private
String
lineSeq
;
}
erp-system/src/main/java/com/topsunit/scanservice/ximai/dto/InvmlDto.java
View file @
35cee4a6
...
...
@@ -43,6 +43,10 @@ public class InvmlDto {
*/
@ApiModelProperty
(
"库存数量"
)
private
BigDecimal
ml005
;
@ApiModelProperty
(
"未确认占用数量"
)
private
BigDecimal
reservedQuantity
;
@ApiModelProperty
(
"可用库存数量"
)
private
BigDecimal
availableQuantity
;
/**
* 最近入库日
*/
...
...
erp-system/src/main/java/com/topsunit/scanservice/ximai/dto/MoctaDto.java
View file @
35cee4a6
...
...
@@ -210,6 +210,12 @@ public class MoctaDto {
private
String
modiDate
;
@ApiModelProperty
(
"批次号"
)
private
String
batchNo
;
@ApiModelProperty
(
"默认仓库(扫码入库)"
)
private
String
tg010
;
@ApiModelProperty
(
"默认库位(扫码入库)"
)
private
String
tg036
;
@ApiModelProperty
(
"默认入库数量(扫码入库)"
)
private
BigDecimal
tg011
;
/**
...
...
erp-system/src/main/java/com/topsunit/scanservice/ximai/dto/StockSaleOutDto.java
View file @
35cee4a6
...
...
@@ -18,6 +18,8 @@ public class StockSaleOutDto {
List
<
StockSaleOutDetail
>
data
;
@Data
public
static
class
StockSaleOutDetail
{
@ApiModelProperty
(
"通知单序号"
)
String
to003
;
@ApiModelProperty
(
"物料号"
)
String
materialNo
;
@ApiModelProperty
(
"物料名称"
)
...
...
@@ -26,7 +28,29 @@ public class StockSaleOutDto {
String
planOutDate
;
@ApiModelProperty
(
"单位"
)
String
unit
;
@ApiModelProperty
(
"交货数量"
)
@ApiModelProperty
(
"通知单销售总数量"
)
BigDecimal
totalQuantity
;
@ApiModelProperty
(
"已确认出库数量"
)
BigDecimal
confirmedOutQuantity
;
@ApiModelProperty
(
"已申请未确认数量"
)
BigDecimal
unconfirmedOutQuantity
;
@ApiModelProperty
(
"待拣货数量(可继续申请)"
)
BigDecimal
deliverQuantity
;
@ApiModelProperty
(
"未确认出库明细"
)
List
<
StockPickDetail
>
unconfirmedPicks
;
@Data
public
static
class
StockPickDetail
{
@ApiModelProperty
(
"通知单序号"
)
String
to003
;
@ApiModelProperty
(
"仓库"
)
String
warehouse
;
@ApiModelProperty
(
"库位"
)
String
location
;
@ApiModelProperty
(
"批号"
)
String
batchNo
;
@ApiModelProperty
(
"数量"
)
BigDecimal
outQuantity
;
}
}
}
erp-system/src/main/java/com/topsunit/scanservice/ximai/dto/StockSaleOutParams.java
View file @
35cee4a6
...
...
@@ -19,6 +19,8 @@ public class StockSaleOutParams {
List
<
StockSaleOutParams
.
StockSaleOutDetail
>
data
;
@Data
public
static
class
StockSaleOutDetail
{
@ApiModelProperty
(
"通知单序号"
)
String
to003
;
@ApiModelProperty
(
"物料号"
)
String
materialNo
;
@ApiModelProperty
(
"物料名称"
)
...
...
erp-system/src/main/java/com/topsunit/scanservice/ximai/service/CopthService.java
View file @
35cee4a6
...
...
@@ -72,9 +72,15 @@ public class CopthService {
for
(
StockSaleOutParams
.
StockSaleOutDetail
s
:
params
.
getData
()){
s
.
setWarehouse
(
StrUtil
.
trim
(
s
.
getWarehouse
()));
s
.
setLocation
(
StrUtil
.
trim
(
s
.
getLocation
()));
//查询出货通知单明细
Copto
copto
=
coptoDao
.
findFirstByTo001AndTo002AndTo007
(
"251"
,
params
.
getApplyNo
(),
s
.
getMaterialNo
())
.
orElseThrow
(()->
new
TopsunitException
(
MessageUtils
.
getMessage
(
"未找到出货通知单明细:{0},{1}"
,
params
.
getApplyNo
(),
s
.
getMaterialNo
())));
//查询出货通知单明细(按序号定位,同品号多行时不可仅用物料号)
Copto
copto
;
if
(
StringUtils
.
isNotBlank
(
s
.
getTo003
()))
{
copto
=
coptoDao
.
findFirstByTo001AndTo002AndTo003
(
"251"
,
params
.
getApplyNo
(),
StrUtil
.
trim
(
s
.
getTo003
()))
.
orElseThrow
(()
->
new
TopsunitException
(
MessageUtils
.
getMessage
(
"未找到出货通知单明细:{0},{1}"
,
params
.
getApplyNo
(),
s
.
getTo003
())));
}
else
{
copto
=
coptoDao
.
findFirstByTo001AndTo002AndTo007
(
"251"
,
params
.
getApplyNo
(),
s
.
getMaterialNo
())
.
orElseThrow
(()
->
new
TopsunitException
(
MessageUtils
.
getMessage
(
"未找到出货通知单明细:{0},{1}"
,
params
.
getApplyNo
(),
s
.
getMaterialNo
())));
}
//查询销售订单明细
Coptd
coptd
=
coptdDao
.
findFirstByTd001AndTd002AndTd003
(
copto
.
getTo004
(),
copto
.
getTo005
(),
copto
.
getTo006
())
.
orElseThrow
(()->
new
TopsunitException
(
MessageUtils
.
getMessage
(
"未找到销售订单:{0},{1},{2}"
,
copto
.
getTo004
(),
copto
.
getTo005
(),
copto
.
getTo006
())));
...
...
erp-system/src/main/java/com/topsunit/scanservice/ximai/service/CoptoService.java
View file @
35cee4a6
...
...
@@ -16,7 +16,6 @@ import org.springframework.stereotype.Service;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
...
...
@@ -43,28 +42,49 @@ public class CoptoService {
}
//查询已出库通知单数据,扣减相应数量
Map
<
String
,
List
<
Copth
>>
copthMap
=
copthDao
.
findByTh045AndTh046
(
"251"
,
params
.
getSaleOutNo
()).
stream
()
.
collect
(
Collectors
.
groupingBy
(
s
->
StrUtil
.
trim
(
s
.
getTh004
())));
Map
<
String
,
BigDecimal
>
copthQuantityMap
=
new
HashMap
<>();
copthMap
.
forEach
((
k
,
v
)->{
copthQuantityMap
.
put
(
k
,
BigDecimal
.
ZERO
);
v
.
forEach
(
s
->{
copthQuantityMap
.
put
(
k
,
copthQuantityMap
.
get
(
k
).
add
(
s
.
getTh008
()));
});
});
.
collect
(
Collectors
.
groupingBy
(
copth
->
StrUtil
.
trim
(
copth
.
getTh047
())));
list
.
forEach
(
s
->{
StockSaleOutDto
.
StockSaleOutDetail
saleOutDetail
=
new
StockSaleOutDto
.
StockSaleOutDetail
();
if
(
copthQuantityMap
.
containsKey
(
StrUtil
.
trim
(
s
.
getTo007
()))){
BigDecimal
tempQuantity
=
NumberUtil
.
max
(
s
.
getTo024
().
subtract
(
copthQuantityMap
.
get
(
StrUtil
.
trim
(
s
.
getTo007
()))),
BigDecimal
.
ZERO
);
saleOutDetail
.
setDeliverQuantity
(
tempQuantity
);
}
else
{
saleOutDetail
.
setDeliverQuantity
(
s
.
getTo024
());
String
materialNo
=
StrUtil
.
trim
(
s
.
getTo007
());
String
lineSeq
=
StrUtil
.
trim
(
s
.
getTo003
());
BigDecimal
totalQuantity
=
s
.
getTo024
()
!=
null
?
s
.
getTo024
()
:
BigDecimal
.
ZERO
;
BigDecimal
confirmedOutQuantity
=
BigDecimal
.
ZERO
;
BigDecimal
unconfirmedOutQuantity
=
BigDecimal
.
ZERO
;
List
<
StockSaleOutDto
.
StockSaleOutDetail
.
StockPickDetail
>
unconfirmedPicks
=
new
ArrayList
<>();
List
<
Copth
>
lineCopthList
=
copthMap
.
getOrDefault
(
lineSeq
,
new
ArrayList
<>());
for
(
Copth
copth
:
lineCopthList
)
{
if
(!
materialNo
.
equals
(
StrUtil
.
trim
(
copth
.
getTh004
())))
{
continue
;
}
BigDecimal
qty
=
copth
.
getTh008
()
!=
null
?
copth
.
getTh008
()
:
BigDecimal
.
ZERO
;
if
(
"Y"
.
equalsIgnoreCase
(
StrUtil
.
trim
(
copth
.
getTh020
())))
{
confirmedOutQuantity
=
confirmedOutQuantity
.
add
(
qty
);
}
else
{
unconfirmedOutQuantity
=
unconfirmedOutQuantity
.
add
(
qty
);
StockSaleOutDto
.
StockSaleOutDetail
.
StockPickDetail
pick
=
new
StockSaleOutDto
.
StockSaleOutDetail
.
StockPickDetail
();
pick
.
setTo003
(
lineSeq
);
pick
.
setWarehouse
(
StrUtil
.
trim
(
copth
.
getTh007
()));
pick
.
setLocation
(
StrUtil
.
trim
(
copth
.
getTh056
()));
pick
.
setBatchNo
(
StrUtil
.
trim
(
copth
.
getTh017
()));
pick
.
setOutQuantity
(
qty
);
unconfirmedPicks
.
add
(
pick
);
}
}
if
(
saleOutDetail
.
getDeliverQuantity
().
compareTo
(
BigDecimal
.
ZERO
)<=
0
){
BigDecimal
deliverQuantity
=
NumberUtil
.
max
(
totalQuantity
.
subtract
(
confirmedOutQuantity
).
subtract
(
unconfirmedOutQuantity
),
BigDecimal
.
ZERO
);
if
(
deliverQuantity
.
compareTo
(
BigDecimal
.
ZERO
)
<=
0
&&
unconfirmedPicks
.
isEmpty
())
{
return
;
}
StockSaleOutDto
.
StockSaleOutDetail
saleOutDetail
=
new
StockSaleOutDto
.
StockSaleOutDetail
();
saleOutDetail
.
setTotalQuantity
(
totalQuantity
);
saleOutDetail
.
setConfirmedOutQuantity
(
confirmedOutQuantity
);
saleOutDetail
.
setUnconfirmedOutQuantity
(
unconfirmedOutQuantity
);
saleOutDetail
.
setDeliverQuantity
(
deliverQuantity
);
saleOutDetail
.
setUnconfirmedPicks
(
unconfirmedPicks
);
saleOutDetail
.
setTo003
(
lineSeq
);
saleOutDetail
.
setPlanOutDate
(
s
.
getUdf01
());
saleOutDetail
.
setMaterialName
(
StrUtil
.
trim
(
s
.
getTo008
()));
saleOutDetail
.
setMaterialNo
(
StrUtil
.
trim
(
s
.
getTo007
())
);
saleOutDetail
.
setMaterialNo
(
materialNo
);
saleOutDetail
.
setUnit
(
StrUtil
.
trim
(
s
.
getTo010
()));
data
.
add
(
saleOutDetail
);
});
...
...
erp-system/src/main/java/com/topsunit/scanservice/ximai/service/InvmcService.java
View file @
35cee4a6
...
...
@@ -6,6 +6,8 @@ import com.topsunit.scanservice.ximai.dao.*;
import
com.topsunit.scanservice.ximai.dto.*
;
import
com.topsunit.scanservice.ximai.dto.mapper.InvmbMapper
;
import
com.topsunit.scanservice.ximai.dto.mapper.InvmlMapper
;
import
cn.hutool.core.util.StrUtil
;
import
com.topsunit.scanservice.ximai.entity.Copth
;
import
com.topsunit.scanservice.ximai.entity.Invma
;
import
com.topsunit.scanservice.ximai.entity.Invmb
;
import
com.topsunit.scanservice.ximai.entity.Invmc
;
...
...
@@ -53,6 +55,8 @@ public class InvmcService {
private
InvmlMapper
invmlMapper
;
@Autowired
private
WarehouseArriveDao
warehouseArriveDao
;
@Autowired
private
CopthDao
copthDao
;
public
List
<
InvmlDto
>
getInvmlList
(
InvmlCriteria
criteria
)
{
Specification
<
Invml
>
query
=
new
Specification
<
Invml
>()
{
...
...
@@ -79,11 +83,51 @@ public class InvmcService {
invmbDao
.
findById
(
criteria
.
getMl001
()).
orElseThrow
(()->
new
TopsunitException
(
MessageUtils
.
getMessage
(
"未找到物料:"
)+
criteria
.
getMl001
()));
List
<
IInvmlDto
>
data
=
invmlDao
.
findJoinInvmb
(
criteria
.
getMl001
(),
criteria
.
getMl002
(),
criteria
.
getGtStock
());
return
data
.
stream
().
map
(
s
->{
Map
<
String
,
BigDecimal
>
reservedMap
=
buildUnconfirmedReservedMap
(
criteria
.
getSaleOutNo
(),
criteria
.
getMl001
(),
criteria
.
getLineSeq
());
return
data
.
stream
().
map
(
s
->
{
InvmlDto
temp
=
new
InvmlDto
();
BeanUtils
.
copyProperties
(
s
,
temp
);
applyAvailableQuantity
(
temp
,
reservedMap
);
return
temp
;
}).
collect
(
Collectors
.
toList
());
}).
filter
(
dto
->
dto
.
getAvailableQuantity
()
==
null
||
dto
.
getAvailableQuantity
().
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
.
collect
(
Collectors
.
toList
());
}
private
Map
<
String
,
BigDecimal
>
buildUnconfirmedReservedMap
(
String
saleOutNo
,
String
materialNo
,
String
lineSeq
)
{
Map
<
String
,
BigDecimal
>
reservedMap
=
new
java
.
util
.
HashMap
<>();
if
(
StringUtils
.
isBlank
(
saleOutNo
)
||
StringUtils
.
isBlank
(
materialNo
))
{
return
reservedMap
;
}
List
<
Copth
>
pendingList
=
copthDao
.
findByTh045AndTh046
(
"251"
,
saleOutNo
).
stream
()
.
filter
(
c
->
StrUtil
.
trim
(
materialNo
).
equals
(
StrUtil
.
trim
(
c
.
getTh004
())))
.
filter
(
c
->
StringUtils
.
isBlank
(
lineSeq
)
||
StrUtil
.
trim
(
lineSeq
).
equals
(
StrUtil
.
trim
(
c
.
getTh047
())))
.
filter
(
c
->
!
"Y"
.
equalsIgnoreCase
(
StrUtil
.
trim
(
c
.
getTh020
())))
.
collect
(
Collectors
.
toList
());
for
(
Copth
copth
:
pendingList
)
{
String
key
=
buildInvmlKey
(
copth
.
getTh007
(),
copth
.
getTh056
(),
copth
.
getTh017
());
BigDecimal
qty
=
copth
.
getTh008
()
!=
null
?
copth
.
getTh008
()
:
BigDecimal
.
ZERO
;
reservedMap
.
merge
(
key
,
qty
,
BigDecimal:
:
add
);
}
return
reservedMap
;
}
private
String
buildInvmlKey
(
String
warehouse
,
String
location
,
String
batchNo
)
{
return
StrUtil
.
trim
(
warehouse
)
+
"|"
+
StrUtil
.
trim
(
location
)
+
"|"
+
StrUtil
.
trim
(
batchNo
);
}
private
void
applyAvailableQuantity
(
InvmlDto
dto
,
Map
<
String
,
BigDecimal
>
reservedMap
)
{
BigDecimal
stock
=
dto
.
getMl005
()
!=
null
?
dto
.
getMl005
()
:
BigDecimal
.
ZERO
;
String
key
=
buildInvmlKey
(
dto
.
getMl002
(),
dto
.
getMl003
(),
dto
.
getMl004
());
BigDecimal
reserved
=
reservedMap
.
getOrDefault
(
key
,
BigDecimal
.
ZERO
);
dto
.
setReservedQuantity
(
reserved
);
BigDecimal
available
=
stock
.
subtract
(
reserved
);
if
(
available
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
{
available
=
BigDecimal
.
ZERO
;
}
dto
.
setAvailableQuantity
(
available
);
}
/**
...
...
erp-system/src/main/java/com/topsunit/scanservice/ximai/service/MoctaService.java
View file @
35cee4a6
...
...
@@ -3,15 +3,15 @@ package com.topsunit.scanservice.ximai.service;
import
com.topsunit.scanservice.ximai.common.AppConfig
;
import
com.topsunit.scanservice.ximai.common.FileView
;
import
com.topsunit.scanservice.ximai.common.SmbFileSystem
;
import
com.topsunit.scanservice.ximai.dao.InvmbDao
;
import
com.topsunit.scanservice.ximai.dao.MoctaDao
;
import
com.topsunit.scanservice.ximai.dao.MoctgDao
;
import
com.topsunit.scanservice.ximai.dao.MoctbDao
;
import
com.topsunit.scanservice.ximai.dao.*
;
import
com.topsunit.scanservice.ximai.dto.*
;
import
com.topsunit.scanservice.ximai.dto.mapper.MoctaMapper
;
import
com.topsunit.scanservice.ximai.entity.Invmc
;
import
com.topsunit.scanservice.ximai.entity.InvmcId
;
import
com.topsunit.scanservice.ximai.entity.Invml
;
import
com.topsunit.scanservice.ximai.entity.Mocta
;
import
com.topsunit.scanservice.ximai.entity.Moctb
;
import
java.math.BigDecimal
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
...
...
@@ -48,6 +48,8 @@ public class MoctaService {
private
AppConfig
appConfig
;
@Autowired
private
MoctgDao
moctgDao
;
@Autowired
private
InvmcDao
invmcDao
;
private
final
MoctaDao
moctaDao
;
...
...
@@ -71,14 +73,36 @@ public class MoctaService {
public
Optional
<
MoctaDto
>
get
(
MoctaIdCriteria
criteria
)
{
return
moctaDao
.
findById
(
moctaMapper
.
toMoctaId
(
criteria
))
.
map
(
i
->
{
.
map
(
i
->
{
MoctaDto
dto
=
moctaMapper
.
toMoctaDto
(
i
);
String
batchNo
=
this
.
buildFinishedProductBatch
(
dto
.
getTa006
(
));
dto
.
setBatchNo
(
batchN
o
);
dto
.
setBatchNo
(
this
.
buildFinishedProductBatch
(
dto
.
getTa006
()
));
this
.
fillStorageDefaults
(
dt
o
);
return
dto
;
});
}
/**
* 扫码入库:带出默认仓库、库位、可入库数量
*/
private
void
fillStorageDefaults
(
MoctaDto
dto
)
{
invmbDao
.
findById
(
dto
.
getTa006
()).
ifPresent
(
invmb
->
{
String
warehouse
=
StringUtils
.
isNotBlank
(
dto
.
getTa020
())
?
dto
.
getTa020
().
trim
()
:
(
StringUtils
.
isNotBlank
(
invmb
.
getMb017
())
?
invmb
.
getMb017
().
trim
()
:
null
);
if
(
StringUtils
.
isNotBlank
(
warehouse
))
{
dto
.
setTg010
(
warehouse
);
invmcDao
.
findById
(
new
InvmcId
(
invmb
.
getMb001
(),
warehouse
))
.
ifPresent
(
invmc
->
{
if
(
StringUtils
.
isNotBlank
(
invmc
.
getMc015
()))
{
dto
.
setTg036
(
invmc
.
getMc015
().
trim
());
}
});
}
});
BigDecimal
ta015
=
dto
.
getTa015
()
!=
null
?
dto
.
getTa015
()
:
BigDecimal
.
ZERO
;
dto
.
setTg011
(
ta015
);
}
public
MoctaDocDto
getForDoc2
(
MoctaIdCriteria
criteria
)
{
MoctaDocDto
dto
=
moctaDao
.
findById
(
moctaMapper
.
toMoctaId
(
criteria
))
.
map
(
moctaMapper:
:
toMoctaDocDto
).
orElse
(
new
MoctaDocDto
());
...
...
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