Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gs1-office-web-sit
Overview
Overview
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
吴迪
gs1-office-web-sit
Commits
034976e1
Commit
034976e1
authored
Dec 13, 2021
by
唐功亮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
回复代码
parent
848c7084
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
37 deletions
+32
-37
BarcodeController.java
...o/office/modules/manage/controller/BarcodeController.java
+32
-37
No files found.
src/main/java/io/office/modules/manage/controller/BarcodeController.java
View file @
034976e1
package
io
.
office
.
modules
.
manage
.
controller
;
/*
import com.github.mbhk.barcode4j.Configuration;
import
com.github.mbhk.barcode4j.Configuration
;
import
io.office.modules.app.annotation.Login
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
...
...
@@ -23,11 +23,7 @@ import java.awt.image.BufferedImage;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.util.logging.Level
;
import java.util.logging.Logger;*/
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.logging.Logger
;
/**
* 生成一维码方法
*
...
...
@@ -38,50 +34,49 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping
(
"/barcodegeneration"
)
public
class
BarcodeController
{
//TODO tgl jar包报错 找张云飞
/*private final Log logger = LogFactory.getLog(getClass());
private
final
Log
logger
=
LogFactory
.
getLog
(
getClass
());
public Log getLogger() {
return logger;
}
*//** Parameter name for the message *//*
public
Log
getLogger
()
{
return
logger
;
}
/** Parameter name for the message */
public
static
final
String
BARCODE_MSG
=
"msg"
;
*//** Parameter name for the barcode type *//*
/** Parameter name for the barcode type */
public
static
final
String
BARCODE_TYPE
=
"type"
;
*//** Parameter name for the barcode height *//*
/** Parameter name for the barcode height */
public
static
final
String
BARCODE_HEIGHT
=
"height"
;
*//** Parameter name for the module width *//*
/** Parameter name for the module width */
public
static
final
String
BARCODE_MODULE_WIDTH
=
"mw"
;
*//** Parameter name for the wide factor *//*
/** Parameter name for the wide factor */
public
static
final
String
BARCODE_WIDE_FACTOR
=
"wf"
;
*//** Parameter name for the quiet zone *//*
/** Parameter name for the quiet zone */
public
static
final
String
BARCODE_QUIET_ZONE
=
"qz"
;
*//** Parameter name for the human-readable placement *//*
/** Parameter name for the human-readable placement */
public
static
final
String
BARCODE_HUMAN_READABLE_POS
=
"hrp"
;
*//** Parameter name for the output format *//*
/** Parameter name for the output format */
public
static
final
String
BARCODE_FORMAT
=
"fmt"
;
*//** Parameter name for the image resolution (for bitmaps) *//*
/** Parameter name for the image resolution (for bitmaps) */
public
static
final
String
BARCODE_IMAGE_RESOLUTION
=
"res"
;
*//** Parameter name for the grayscale or b/w image (for bitmaps) *//*
/** Parameter name for the grayscale or b/w image (for bitmaps) */
public
static
final
String
BARCODE_IMAGE_GRAYSCALE
=
"gray"
;
*//** Parameter name for the font size of the human readable display *//*
/** Parameter name for the font size of the human readable display */
public
static
final
String
BARCODE_HUMAN_READABLE_SIZE
=
"hrsize"
;
*//** Parameter name for the font name of the human readable display *//*
/** Parameter name for the font name of the human readable display */
public
static
final
String
BARCODE_HUMAN_READABLE_FONT
=
"hrfont"
;
*//** Parameter name for the pattern to format the human readable message *//*
/** Parameter name for the pattern to format the human readable message */
public
static
final
String
BARCODE_HUMAN_READABLE_PATTERN
=
"hrpattern"
;
private
static
final
String
ERROR_WHILE_GENERATING_BARCODE
=
"Error while generating barcode"
;
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
BarcodeController
.
class
.
getName
());
@Login
@GetMapping
(
value
=
"/api/gensvg"
)
public void getBarcode(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
System.out.println("barcode................");
public
void
getBarcode
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
try
{
System
.
out
.
println
(
"barcode................"
);
final
String
format
=
determineFormat
(
request
);
final
Orientation
orientation
=
Orientation
.
ZERO
;
final
Configuration
cfg
=
buildCfg
(
request
);
...
...
@@ -131,9 +126,9 @@ public class BarcodeController {
final
String
gray
=
request
.
getParameter
(
BARCODE_IMAGE_GRAYSCALE
);
final
BitmapCanvasProvider
bitmap
=
"true"
.
equalsIgnoreCase
(
gray
)
?
new
BitmapCanvasProvider
(
bout
,
format
,
resolution
,
BufferedImage
.
TYPE_BYTE_GRAY
,
true
,
orientation)
orientation
)
:
new
BitmapCanvasProvider
(
bout
,
format
,
resolution
,
BufferedImage
.
TYPE_BYTE_BINARY
,
false
,
orientation);
orientation
);
gen
.
generateBarcode
(
bitmap
,
msg
);
bitmap
.
finish
();
}
...
...
@@ -157,16 +152,16 @@ public class BarcodeController {
LOGGER
.
log
(
Level
.
SEVERE
,
ERROR_WHILE_GENERATING_BARCODE
,
e
);
throw
new
ServletException
(
e
);
}
}
}
*/
/**
/**
* Check the request for the desired output format.
*
* @param request
* the request to use
* @return MIME type of the desired output format.
*/
/*
*/
protected
String
determineFormat
(
HttpServletRequest
request
)
{
String
format
=
request
.
getParameter
(
BARCODE_FORMAT
);
format
=
MimeTypes
.
expandFormat
(
format
);
...
...
@@ -176,14 +171,14 @@ public class BarcodeController {
return
format
;
}
*/
/**
/**
* Build an Configuration object from the request.
*
* @param request
* the request to use
* @return the newly built COnfiguration object
*
*/
/*
*/
protected
Configuration
buildCfg
(
HttpServletRequest
request
)
{
// Get type
String
type
=
request
.
getParameter
(
BARCODE_TYPE
);
...
...
@@ -232,5 +227,5 @@ public class BarcodeController {
}
return
cfg
;
}
*/
}
}
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