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
6d8ed3b3
Commit
6d8ed3b3
authored
Aug 13, 2019
by
顾俭
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aship/aship#2 防伪码功能-打印:接口
parent
e8a127f1
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
273 additions
and
17 deletions
+273
-17
BarCodePrintService.java
.../java/com/i1/erp/barcode/service/BarCodePrintService.java
+43
-0
IBarCodePrintService.java
...java/com/i1/erp/barcode/service/IBarCodePrintService.java
+8
-0
BarCodePrintClient.java
...main/java/com/i1/erp/barcode/soap/BarCodePrintClient.java
+109
-2
BarcodeGenClient.java
src/main/java/com/i1/erp/barcode/soap/BarcodeGenClient.java
+6
-8
SyncResponseWithList.java
...in/java/com/i1/erp/base/web/dto/SyncResponseWithList.java
+27
-0
PoDtlFileController.java
...ava/com/i1/srm/purchaseOrder/web/PoDtlFileController.java
+36
-6
PoBarcodePrintDto.java
...a/com/i1/srm/purchaseOrder/web/dto/PoBarcodePrintDto.java
+39
-0
query.js
...ain/resources/static/app/srm/purchaseOrder/query/query.js
+5
-1
No files found.
src/main/java/com/i1/erp/barcode/service/BarCodePrintService.java
0 → 100644
View file @
6d8ed3b3
package
com
.
i1
.
erp
.
barcode
.
service
;
import
com.i1.base.exception.IOneServiceException
;
import
com.i1.erp.entity.request.*
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
@Service
public
class
BarCodePrintService
implements
IBarCodePrintService
{
@Override
public
Request
getRequestXml
(
String
organization
,
String
docno
,
String
seq
,
String
barcode
,
String
type
)
throws
IOneServiceException
{
if
(
StringUtils
.
isBlank
(
docno
)
&&
StringUtils
.
isBlank
(
seq
)
&&
StringUtils
.
isBlank
(
barcode
))
{
throw
new
IOneServiceException
(
"防伪码打印参数为空"
);
}
Access
access
=
Access
.
of
(
Authentication
.
of
(
"017552"
,
"tiptop"
),
Connection
.
of
(
"SRM"
,
"192.168.1.1"
),
Organization
.
of
(
organization
),
Locale
.
of
(
"zh_cn"
));
List
<
Field
>
mstFieldList
=
new
ArrayList
<>();
mstFieldList
.
add
(
Field
.
of
(
"docno"
,
docno
));
mstFieldList
.
add
(
Field
.
of
(
"seq"
,
seq
));
mstFieldList
.
add
(
Field
.
of
(
"barcode"
,
barcode
));
mstFieldList
.
add
(
Field
.
of
(
"type"
,
type
));
Record
mstRecord
=
Record
.
of
(
mstFieldList
);
Master
mst
=
Master
.
of
(
mstRecord
,
"MST"
);
RecordSet
recordSet
=
RecordSet
.
of
(
"1"
,
mst
);
List
<
RecordSet
>
recordSetList
=
new
ArrayList
<>();
recordSetList
.
add
(
recordSet
);
RequestContent
requestContent
=
new
RequestContent
();
requestContent
.
setDocument
(
Document
.
of
(
recordSetList
));
requestContent
.
setParameter
(
Parameter
.
of
(
Record
.
of
(
null
)));
return
Request
.
of
(
access
,
requestContent
);
}
}
src/main/java/com/i1/erp/barcode/service/IBarCodePrintService.java
0 → 100644
View file @
6d8ed3b3
package
com
.
i1
.
erp
.
barcode
.
service
;
import
com.i1.base.exception.IOneServiceException
;
import
com.i1.erp.entity.request.Request
;
public
interface
IBarCodePrintService
{
Request
getRequestXml
(
String
organization
,
String
docno
,
String
seq
,
String
barcode
,
String
type
)
throws
IOneServiceException
;
}
src/main/java/com/i1/erp/barcode/soap/BarCodePrintClient.java
View file @
6d8ed3b3
package
com
.
i1
.
erp
.
barcode
.
soap
;
public
class
BarCodePrintClient
{
import
com.i1.base.exception.IOneServiceException
;
import
com.i1.erp.WebServiceClient
;
import
com.i1.erp.barcode.service.IBarCodePrintService
;
import
com.i1.erp.base.web.dto.SyncResponseWithList
;
import
com.i1.erp.entity.request.Field
;
import
com.i1.erp.entity.request.RecordSet
;
import
com.i1.erp.entity.request.Request
;
import
com.i1.erp.entity.response.Document
;
import
com.i1.erp.entity.response.Response
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.cxf.endpoint.Client
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
tw.com.dsc.tiptop.tiptopservicegateway.SRMPrintbarcodeRequestSRMPrintbarcodeRequest
;
import
tw.com.dsc.tiptop.tiptopservicegateway.SRMPrintbarcodeResponseSRMPrintbarcodeResponse
;
import
java.util.ArrayList
;
import
java.util.List
;
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
;
/**
* 防伪码接口只做了动态客户端版本
*/
@Component
public
class
BarCodePrintClient
extends
WebServiceClient
{
@Value
(
"${srm.soapWs.printBarcode}"
)
public
String
ERP_PRINT_BARCODE_OP
;
@Value
(
"${srm.soapWs.wsdlUrl}"
)
private
String
WSDL_URL
;
@Autowired
private
IBarCodePrintService
barCodePrintService
;
private
Logger
logger
=
LoggerFactory
.
getLogger
(
BarcodeGenClient
.
class
);
public
SyncResponseWithList
getBarcodePrintUrls
(
String
organization
,
String
docno
,
String
seq
,
String
barcode
,
String
type
)
{
List
<
String
>
urls
=
new
ArrayList
<>();
try
{
// xml
logger
.
info
(
"prepare gen barcode {}"
,
organization
+
"-"
+
docno
+
"-"
+
seq
+
"-"
+
barcode
+
"-"
+
type
);
Request
requestXml
=
barCodePrintService
.
getRequestXml
(
organization
,
docno
,
seq
,
barcode
,
type
);
if
(
requestXml
==
null
)
{
logger
.
error
(
"error:防伪码打印地址无法生成XML结构"
);
return
SyncResponseWithList
.
of
(
FAIL_CODE
,
"防伪码打印地址无法生成XML结构"
,
urls
);
}
// request
SRMPrintbarcodeRequestSRMPrintbarcodeRequest
printbarcodeRequest
=
new
SRMPrintbarcodeRequestSRMPrintbarcodeRequest
();
printbarcodeRequest
.
setRequest
(
covertObjectToXML
(
requestXml
,
Request
.
class
));
logger
.
info
(
printbarcodeRequest
.
getRequest
());
if
(
StringUtils
.
isBlank
(
WSDL_URL
)
||
StringUtils
.
isBlank
(
ERP_PRINT_BARCODE_OP
))
{
throw
new
IOneServiceException
(
"WSDL不可为空."
);
}
Client
client
=
getClient
(
WSDL_URL
);
Object
[]
objects
=
client
.
invoke
(
ERP_PRINT_BARCODE_OP
,
new
Object
[]{
printbarcodeRequest
});
client
.
destroy
();
// response
if
(
objects
!=
null
&&
objects
.
length
>
0
)
{
SRMPrintbarcodeResponseSRMPrintbarcodeResponse
printbarcodeResponse
=
(
SRMPrintbarcodeResponseSRMPrintbarcodeResponse
)
objects
[
0
];
logger
.
info
(
printbarcodeResponse
.
getResponse
());
Response
response
=
convertXMLToObject
(
printbarcodeResponse
.
getResponse
(),
Response
.
class
);
if
(
response
.
getExecution
().
getStatus
().
getCode
().
equalsIgnoreCase
(
"0"
))
{
Document
document
=
response
.
getResponseContent
().
getDocument
();
List
<
RecordSet
>
recordSetList
=
new
ArrayList
<>();
if
(
document
!=
null
)
{
recordSetList
=
response
.
getResponseContent
().
getDocument
().
getRecordSetList
();
}
if
(
document
!=
null
&&
recordSetList
!=
null
&&
recordSetList
.
size
()
>
0
)
{
for
(
RecordSet
recordSet
:
recordSetList
)
{
List
<
Field
>
fieldList
=
recordSet
.
getMaster
().
getRecord
().
getFieldList
();
for
(
Field
field
:
fieldList
)
{
if
(
"url"
.
equals
(
field
.
getName
()))
{
urls
.
add
(
field
.
getValue
());
}
}
}
}
else
{
logger
.
warn
(
"warn:"
,
"erp无返回资料"
);
}
return
SyncResponseWithList
.
of
(
SUCCESS_CODE
,
"获取防伪码打印地址成功"
,
urls
);
}
else
{
String
errorDetails
=
String
.
format
(
"失败码:%s,原因:%s,SQL:%s"
,
safeString
(
response
.
getExecution
().
getStatus
().
getCode
()),
safeString
(
response
.
getExecution
().
getStatus
().
getDescription
()),
safeString
(
response
.
getExecution
().
getStatus
().
getSqlcode
()));
return
SyncResponseWithList
.
of
(
FAIL_CODE
,
errorDetails
,
urls
);
}
}
else
{
logger
.
error
(
"ERP无响应."
);
return
SyncResponseWithList
.
of
(
FAIL_CODE
,
"ERP无响应"
,
urls
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"e"
,
e
);
return
SyncResponseWithList
.
of
(
FAIL_CODE
,
e
.
getMessage
(),
urls
);
}
}
}
\ No newline at end of file
src/main/java/com/i1/erp/barcode/soap/BarcodeGenClient.java
View file @
6d8ed3b3
...
...
@@ -23,25 +23,23 @@ import static com.i1.srm.utils.SafeType.safeString;
@Component
public
class
BarcodeGenClient
extends
WebServiceClient
{
// 防伪码接口只做了动态客户端版本
@Value
(
"${srm.soapWs.wsDynamicClient}"
)
public
Boolean
wsDynamicClient
;
@Value
(
"${srm.soapWs.wsdlUrl}"
)
private
String
WSDL_URL
;
@Value
(
"${srm.soapWs.genBarcode}"
)
public
String
ERP_GEN_BARCODE_OP
;
@Value
(
"${srm.soapWs.wsdlUrl}"
)
private
String
WSDL_URL
;
private
Logger
logger
=
LoggerFactory
.
getLogger
(
BarcodeGenClient
.
class
);
@Autowired
private
BarCodeGenService
barCodeGenService
l
;
private
BarCodeGenService
barCodeGenService
;
public
SyncResponse
genBarcode
(
PoBarcodeDto
input
)
{
try
{
// xml
logger
.
info
(
"prepare gen barcode {}"
,
input
.
getFactoryUid
()
+
"-"
+
input
.
getPurchaseOrderUid
());
Request
requestXml
=
barCodeGenService
l
.
genXml
(
input
);
Request
requestXml
=
barCodeGenService
.
genXml
(
input
);
if
(
requestXml
==
null
)
{
logger
.
error
(
"error:防伪码申请无法生成XML结构"
);
return
SyncResponse
.
of
(
FAIL_CODE
,
"防伪码申请无法生成XML结构"
);
...
...
@@ -69,7 +67,7 @@ public class BarcodeGenClient extends WebServiceClient {
if
(
response
.
getExecution
().
getStatus
().
getCode
().
equalsIgnoreCase
(
"0"
))
{
return
SyncResponse
.
of
(
SUCCESS_CODE
,
"申请防伪码成功"
);
}
else
{
String
errorDetails
=
String
.
format
(
"失败码:%s
, 原因: %s, SQL:
"
,
String
errorDetails
=
String
.
format
(
"失败码:%s
, 原因:%s,SQL:%s
"
,
safeString
(
response
.
getExecution
().
getStatus
().
getCode
()),
safeString
(
response
.
getExecution
().
getStatus
().
getDescription
()),
safeString
(
response
.
getExecution
().
getStatus
().
getSqlcode
()));
...
...
src/main/java/com/i1/erp/base/web/dto/SyncResponseWithList.java
0 → 100644
View file @
6d8ed3b3
package
com
.
i1
.
erp
.
base
.
web
.
dto
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
java.util.List
;
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
SyncResponseWithList
extends
SyncResponse
{
private
List
<
String
>
content
;
public
SyncResponseWithList
(
String
code
,
String
message
,
List
<
String
>
content
)
{
super
(
code
,
message
);
this
.
content
=
content
;
}
public
List
<
String
>
getContent
()
{
return
content
;
}
public
void
setContent
(
List
<
String
>
content
)
{
this
.
content
=
content
;
}
public
static
SyncResponseWithList
of
(
String
code
,
String
message
,
List
<
String
>
content
)
{
return
new
SyncResponseWithList
(
code
,
message
,
content
);
}
}
src/main/java/com/i1/srm/purchaseOrder/web/PoDtlFileController.java
View file @
6d8ed3b3
...
...
@@ -3,6 +3,8 @@ package com.i1.srm.purchaseOrder.web;
import
com.i1.base.exception.IOneServiceException
;
import
com.i1.base.exception.IOneWebRestfulException
;
import
com.i1.base.web.AbstractController
;
import
com.i1.erp.barcode.soap.BarCodePrintClient
;
import
com.i1.erp.base.web.dto.SyncResponseWithList
;
import
com.i1.srm.am.entity.Function
;
import
com.i1.srm.am.entity.Resource
;
import
com.i1.srm.am.service.ResourcePermission
;
...
...
@@ -11,6 +13,7 @@ import com.i1.srm.deliveryOrder.service.IDoDtlFileService;
import
com.i1.srm.purchaseOrder.dao.entity.PoDtlFile
;
import
com.i1.srm.purchaseOrder.service.IPoDtlFileService
;
import
com.i1.srm.purchaseOrder.service.IPoMstFileService
;
import
com.i1.srm.purchaseOrder.web.dto.PoBarcodePrintDto
;
import
com.i1.srm.purchaseOrder.web.dto.PoDtlFileDto
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -21,10 +24,14 @@ import org.springframework.data.domain.Pageable;
import
org.springframework.web.bind.annotation.*
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
static
com
.
i1
.
erp
.
base
.
web
.
dto
.
SyncResponseCode
.
FAIL_CODE
;
import
static
com
.
i1
.
erp
.
base
.
web
.
dto
.
SyncResponseCode
.
SUCCESS_CODE
;
@RestController
@RequestMapping
(
"/purchaseOrderDetails"
)
...
...
@@ -37,13 +44,15 @@ public class PoDtlFileController extends AbstractController<PoDtlFile, PoDtlFile
private
IDoDtlFileService
doDtlFileService
;
@Autowired
private
IPoMstFileService
poMstFileService
;
@Autowired
private
BarCodePrintClient
barCodePrintClient
;
@Override
protected
IPoDtlFileService
getService
()
{
return
service
;
}
@ResourcePermission
(
values
=
{
Resource
.
QUERY
})
@ResourcePermission
(
values
=
{
Resource
.
QUERY
})
@RequestMapping
(
value
=
"/getAllByPageAndExample"
,
method
=
RequestMethod
.
GET
)
public
Page
<
PoDtlFileDto
>
getAllByPageAndExample
(
@RequestParam
String
exampleJson
,
@RequestParam
(
defaultValue
=
"1"
)
int
page
,
@RequestParam
(
defaultValue
=
"100"
)
int
size
)
throws
IOneWebRestfulException
{
try
{
...
...
@@ -53,7 +62,7 @@ public class PoDtlFileController extends AbstractController<PoDtlFile, PoDtlFile
PoDtlFileDto
dtoExample
=
getDtoFromExampleJson
(
exampleJson
);
PoDtlFile
poDtlFile
=
getEntityFromDto
(
dtoExample
);
if
(
null
!=
dtoExample
.
getRequiredDeliveryDateEnd
())
{
if
(
null
!=
dtoExample
.
getRequiredDeliveryDateEnd
())
{
Date
dateEnd
=
dtoExample
.
getRequiredDeliveryDateEnd
();
dateEnd
.
setHours
(
23
);
dateEnd
.
setMinutes
(
59
);
...
...
@@ -69,7 +78,7 @@ public class PoDtlFileController extends AbstractController<PoDtlFile, PoDtlFile
poDtl
.
setRelationAmount
(
doDtlFileService
.
getRelationAmount
(
poDtl
.
getId
()));
}
System
.
out
.
println
(
entities
.
getTotalElements
());
//TODO delete after test
System
.
out
.
println
(
entities
.
getTotalElements
());
//TODO delete after test
return
new
PageImpl
<>(
convertEntitiesToDtos
(
entities
.
getContent
()),
pageable
,
entities
.
getTotalElements
());
}
else
{
throw
new
IOneWebRestfulException
(
"Example is null."
);
...
...
@@ -88,7 +97,7 @@ public class PoDtlFileController extends AbstractController<PoDtlFile, PoDtlFile
PoDtlFileDto
dtoExample
=
getDtoFromExampleJson
(
exampleJson
);
PoDtlFile
entity
=
getEntityFromDto
(
dtoExample
);
if
(
null
!=
dtoExample
.
getRequiredDeliveryDateEnd
())
{
if
(
null
!=
dtoExample
.
getRequiredDeliveryDateEnd
())
{
Date
dateEnd
=
dtoExample
.
getRequiredDeliveryDateEnd
();
dateEnd
.
setHours
(
23
);
dateEnd
.
setMinutes
(
59
);
...
...
@@ -121,14 +130,14 @@ public class PoDtlFileController extends AbstractController<PoDtlFile, PoDtlFile
PoDtlFile
poDtlFile
=
getEntityFromDto
(
dtoExample
);
List
<
String
>
stringMatchFields
=
Arrays
.
asList
(
"poMst.purchaseOrderUid"
);
if
(
null
!=
dtoExample
.
getPoMst
()
&&
null
!=
dtoExample
.
getPoMst
().
getOrderDateEnd
())
{
if
(
null
!=
dtoExample
.
getPoMst
()
&&
null
!=
dtoExample
.
getPoMst
().
getOrderDateEnd
())
{
Date
dateEnd
=
dtoExample
.
getPoMst
().
getOrderDateEnd
();
dateEnd
.
setHours
(
23
);
dateEnd
.
setMinutes
(
59
);
dateEnd
.
setSeconds
(
59
);
dtoExample
.
getPoMst
().
setOrderDateEnd
(
dateEnd
);
}
if
(
null
!=
dtoExample
.
getConfirmedDeliveryDateEnd
())
{
if
(
null
!=
dtoExample
.
getConfirmedDeliveryDateEnd
())
{
Date
dateEnd
=
dtoExample
.
getConfirmedDeliveryDateEnd
();
dateEnd
.
setHours
(
23
);
dateEnd
.
setMinutes
(
59
);
...
...
@@ -195,4 +204,25 @@ public class PoDtlFileController extends AbstractController<PoDtlFile, PoDtlFile
throw
new
IOneWebRestfulException
(
e
);
}
}
@ResourcePermission
(
values
=
{
Resource
.
PRINT_BARCODE
})
@RequestMapping
(
value
=
"/{id}/printBarcode"
,
method
=
RequestMethod
.
GET
)
public
PoBarcodePrintDto
printBarcode
(
@PathVariable
Long
id
)
throws
IOneWebRestfulException
{
try
{
List
<
String
>
urls
=
new
ArrayList
<>();
PoDtlFile
exist
=
getService
().
get
(
id
);
if
(
exist
!=
null
)
{
SyncResponseWithList
responseWithList
=
barCodePrintClient
.
getBarcodePrintUrls
(
exist
.
getPoMst
().
getFactory
().
getFactoryUid
(),
exist
.
getPoMst
().
getPurchaseOrderUid
(),
exist
.
getPoDtlRow
().
toString
(),
""
,
"1"
);
if
(
SUCCESS_CODE
.
equals
(
responseWithList
.
getCode
()))
{
urls
.
addAll
(
responseWithList
.
getContent
());
}
return
new
PoBarcodePrintDto
(
responseWithList
.
getCode
(),
responseWithList
.
getMessage
(),
urls
);
}
else
{
return
new
PoBarcodePrintDto
(
FAIL_CODE
,
"找不到该采购单,id:"
+
id
,
urls
);
}
}
catch
(
IOneServiceException
e
)
{
throw
new
IOneWebRestfulException
(
e
);
}
}
}
src/main/java/com/i1/srm/purchaseOrder/web/dto/PoBarcodePrintDto.java
View file @
6d8ed3b3
package
com
.
i1
.
srm
.
purchaseOrder
.
web
.
dto
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
java.util.List
;
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
PoBarcodePrintDto
{
private
String
code
;
private
String
message
;
private
List
<
String
>
printUrls
;
public
PoBarcodePrintDto
(
String
code
,
String
message
,
List
<
String
>
printUrls
)
{
this
.
code
=
code
;
this
.
message
=
message
;
this
.
printUrls
=
printUrls
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getMessage
()
{
return
message
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
public
List
<
String
>
getPrintUrls
()
{
return
printUrls
;
}
public
void
setPrintUrls
(
List
<
String
>
printUrls
)
{
this
.
printUrls
=
printUrls
;
}
}
src/main/resources/static/app/srm/purchaseOrder/query/query.js
View file @
6d8ed3b3
...
...
@@ -380,7 +380,11 @@ angular.module('IOne').controller('PurchaseOrderQueryController', function ($sco
// to call poDtl api, to call soap ws, to get print urls, to open windows
PoDtlFileService
.
printBarcode
(
$scope
.
selectedPurchaseOrder
.
id
).
then
(
function
(
response
)
{
if
(
response
.
data
&&
response
.
data
.
code
==
'0'
)
{
if
(
response
.
data
&&
response
.
data
.
code
===
'0'
)
{
if
(
response
.
data
.
printUrls
.
length
===
0
)
{
UtilService
.
showWarn
(
"没有可打印的防伪码"
);
return
;
}
angular
.
forEach
(
response
.
data
.
printUrls
,
function
(
url
)
{
try
{
$window
.
open
(
url
);
...
...
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