Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
srm
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
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
Jobs
Commits
Open sidebar
aship
srm
Commits
9af7e0e5
Commit
9af7e0e5
authored
Oct 20, 2019
by
顾俭
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
条码申请数量预扣减 防等待接口时间内重复申请
parent
64d23bdd
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
11 deletions
+46
-11
BarcodeGenClient.java
src/main/java/com/i1/erp/barcode/soap/BarcodeGenClient.java
+22
-0
PoMstFileController.java
...ava/com/i1/srm/purchaseOrder/web/PoMstFileController.java
+23
-11
application.yml
src/main/resources/application.yml
+1
-0
No files found.
src/main/java/com/i1/erp/barcode/soap/BarcodeGenClient.java
View file @
9af7e0e5
...
...
@@ -6,6 +6,9 @@ import com.i1.erp.barcode.service.IBarcodeGenService;
import
com.i1.erp.base.web.dto.SyncResponse
;
import
com.i1.erp.entity.request.Request
;
import
com.i1.erp.entity.response.Response
;
import
com.i1.srm.purchaseOrder.dao.entity.PoDtlFile
;
import
com.i1.srm.purchaseOrder.service.IPoDtlFileService
;
import
com.i1.srm.purchaseOrder.web.dto.PoBarcodeDtlDto
;
import
com.i1.srm.purchaseOrder.web.dto.PoBarcodeDto
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.cxf.endpoint.Client
;
...
...
@@ -17,6 +20,8 @@ import org.springframework.stereotype.Component;
import
tw.com.dsc.tiptop.tiptopservicegateway.SRMGenbarcodeRequestSRMGenbarcodeRequest
;
import
tw.com.dsc.tiptop.tiptopservicegateway.SRMGenbarcodeResponseSRMGenbarcodeResponse
;
import
java.util.Optional
;
import
static
com
.
i1
.
erp
.
base
.
web
.
dto
.
SyncResponseCode
.
FAIL_CODE
;
import
static
com
.
i1
.
erp
.
base
.
web
.
dto
.
SyncResponseCode
.
SUCCESS_CODE
;
import
static
com
.
i1
.
srm
.
utils
.
SafeType
.
safeString
;
...
...
@@ -33,11 +38,17 @@ public class BarcodeGenClient extends WebServiceClient {
@Value
(
"${srm.soapWs.wsdlUrlGenBarcode}"
)
private
String
WSDL_URL
;
@Value
(
"${srm.soapWs.recoveryBarcodeAppliedAmount}"
)
private
Boolean
RECOVERY_APPLIED_AMOUNT
;
private
Logger
logger
=
LoggerFactory
.
getLogger
(
BarcodeGenClient
.
class
);
@Autowired
private
IBarcodeGenService
barcodeGenService
;
@Autowired
private
IPoDtlFileService
poDtlFileService
;
public
SyncResponse
genBarcode
(
PoBarcodeDto
input
)
{
try
{
// xml
...
...
@@ -70,6 +81,17 @@ public class BarcodeGenClient extends WebServiceClient {
if
(
response
.
getExecution
().
getStatus
().
getCode
().
equalsIgnoreCase
(
"0"
))
{
return
SyncResponse
.
of
(
SUCCESS_CODE
,
"申请防伪码成功"
);
}
else
{
if
(
RECOVERY_APPLIED_AMOUNT
)
{
logger
.
info
(
"采购单{}恢复条码申请预扣减数量"
,
input
.
getPurchaseOrderUid
());
for
(
PoBarcodeDtlDto
dtl
:
input
.
getDtl
())
{
Optional
<
PoDtlFile
>
opPoDtl
=
poDtlFileService
.
findByPoMstPurchaseOrderUidAndPoDtlRowAndFactoryFactoryUid
(
input
.
getPurchaseOrderUid
(),
dtl
.
getPoDtlRow
(),
input
.
getFactoryUid
());
if
(
opPoDtl
.
isPresent
())
{
PoDtlFile
poDtlFile
=
opPoDtl
.
get
();
poDtlFile
.
setAppliedAmount
(
poDtlFile
.
getAppliedAmount
().
subtract
(
dtl
.
getBarcodeAmount
()));
poDtlFileService
.
update
(
poDtlFile
);
}
}
}
String
errorDetails
=
String
.
format
(
"失败码:%s, 原因:%s,SQL:%s"
,
safeString
(
response
.
getExecution
().
getStatus
().
getCode
()),
safeString
(
response
.
getExecution
().
getStatus
().
getDescription
()),
...
...
src/main/java/com/i1/srm/purchaseOrder/web/PoMstFileController.java
View file @
9af7e0e5
...
...
@@ -5,8 +5,6 @@ import com.i1.base.web.AbstractController;
import
com.i1.erp.barcode.soap.BarcodeGenClient
;
import
com.i1.erp.base.web.dto.SyncResponse
;
import
com.i1.srm.am.entity.Function
;
import
com.i1.srm.am.entity.Resource
;
import
com.i1.srm.am.service.ResourcePermission
;
import
com.i1.srm.am.service.SecuredPage
;
import
com.i1.srm.purchaseOrder.dao.entity.PoDtlFile
;
import
com.i1.srm.purchaseOrder.dao.entity.PoMstFile
;
...
...
@@ -65,9 +63,21 @@ public class PoMstFileController extends AbstractController<PoMstFile, PoMstFile
String
purchaseOrderUid
=
Objects
.
requireNonNull
(
input
.
getPurchaseOrderUid
());
List
<
PoBarcodeDtlDto
>
dtls
=
Objects
.
requireNonNull
(
input
.
getDtl
());
SyncResponse
syncResponse
=
barcodeGenClient
.
genBarcode
(
input
);
// 更新已申请数量
if
(
SUCCESS_CODE
.
equals
(
syncResponse
.
getCode
()))
{
// check
for
(
PoBarcodeDtlDto
dtl
:
dtls
)
{
Optional
<
PoDtlFile
>
opPoDtl
=
poDtlFileService
.
findByPoMstPurchaseOrderUidAndPoDtlRowAndFactoryFactoryUid
(
purchaseOrderUid
,
dtl
.
getPoDtlRow
(),
factoryUid
);
if
(
opPoDtl
.
isPresent
())
{
PoDtlFile
poDtlFile
=
opPoDtl
.
get
();
BigDecimal
orderAmount
=
poDtlFile
.
getOrderAmount
()
==
null
?
BigDecimal
.
ZERO
:
poDtlFile
.
getOrderAmount
();
BigDecimal
appliedAmount
=
poDtlFile
.
getAppliedAmount
()
==
null
?
BigDecimal
.
ZERO
:
poDtlFile
.
getAppliedAmount
();
BigDecimal
barcodeAmount
=
dtl
.
getBarcodeAmount
()
==
null
?
BigDecimal
.
ZERO
:
dtl
.
getBarcodeAmount
();
if
(
appliedAmount
.
add
(
barcodeAmount
).
compareTo
(
orderAmount
)
>
0
)
{
throw
new
Exception
(
"申请数量不能超过可申请数量,请刷新查看"
);
}
}
}
// 先更新已申请数量,防止接口等待期间重复申请
for
(
PoBarcodeDtlDto
dtl
:
dtls
)
{
Optional
<
PoDtlFile
>
opPoDtl
=
poDtlFileService
.
findByPoMstPurchaseOrderUidAndPoDtlRowAndFactoryFactoryUid
(
purchaseOrderUid
,
dtl
.
getPoDtlRow
(),
factoryUid
);
if
(
opPoDtl
.
isPresent
())
{
...
...
@@ -76,7 +86,9 @@ public class PoMstFileController extends AbstractController<PoMstFile, PoMstFile
poDtlFileService
.
update
(
poDtlFile
);
}
}
}
SyncResponse
syncResponse
=
barcodeGenClient
.
genBarcode
(
input
);
return
syncResponse
;
}
catch
(
Exception
e
)
{
throw
new
IOneWebRestfulException
(
e
);
...
...
src/main/resources/application.yml
View file @
9af7e0e5
...
...
@@ -119,6 +119,7 @@ srm:
voidBarcode
:
SRM_voidbarcode
getBarcodeStatus
:
SRM_getbarcodestatus
fahuoConfirm
:
SRM_fahuoconfirm
recoveryBarcodeAppliedAmount
:
false
email
:
enable
:
true
recipients
:
gujian@benchmarkchina.com,raven@benchmarkchina.com
...
...
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