Commit 034976e1 by 唐功亮

回复代码

parent 848c7084
package io.office.modules.manage.controller; 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 io.office.modules.app.annotation.Login;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
...@@ -23,11 +23,7 @@ import java.awt.image.BufferedImage; ...@@ -23,11 +23,7 @@ import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger;*/ import java.util.logging.Logger;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** /**
* 生成一维码方法 * 生成一维码方法
* *
...@@ -38,50 +34,49 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -38,50 +34,49 @@ import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping("/barcodegeneration") @RequestMapping("/barcodegeneration")
public class BarcodeController { public class BarcodeController {
//TODO tgl jar包报错 找张云飞 private final Log logger = LogFactory.getLog(getClass());
/*private final Log logger = LogFactory.getLog(getClass());
public Log getLogger() { public Log getLogger() {
return logger; return logger;
} }
*//** Parameter name for the message *//* /** Parameter name for the message */
public static final String BARCODE_MSG = "msg"; 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"; 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"; 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"; 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"; 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"; 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"; 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"; 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"; 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"; 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"; 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"; 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"; public static final String BARCODE_HUMAN_READABLE_PATTERN = "hrpattern";
private static final String ERROR_WHILE_GENERATING_BARCODE = "Error while generating barcode"; private static final String ERROR_WHILE_GENERATING_BARCODE = "Error while generating barcode";
private static final Logger LOGGER = Logger.getLogger(BarcodeController.class.getName()); private static final Logger LOGGER = Logger.getLogger(BarcodeController.class.getName());
@Login @Login
@GetMapping(value="/api/gensvg") @GetMapping(value="/api/gensvg")
public void getBarcode(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { public void getBarcode(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try { try {
System.out.println("barcode................"); System.out.println("barcode................");
final String format = determineFormat(request); final String format = determineFormat(request);
final Orientation orientation = Orientation.ZERO; final Orientation orientation = Orientation.ZERO;
final Configuration cfg = buildCfg(request); final Configuration cfg = buildCfg(request);
...@@ -131,9 +126,9 @@ public class BarcodeController { ...@@ -131,9 +126,9 @@ public class BarcodeController {
final String gray = request.getParameter(BARCODE_IMAGE_GRAYSCALE); final String gray = request.getParameter(BARCODE_IMAGE_GRAYSCALE);
final BitmapCanvasProvider bitmap = "true".equalsIgnoreCase(gray) final BitmapCanvasProvider bitmap = "true".equalsIgnoreCase(gray)
? new BitmapCanvasProvider(bout, format, resolution, BufferedImage.TYPE_BYTE_GRAY, true, ? new BitmapCanvasProvider(bout, format, resolution, BufferedImage.TYPE_BYTE_GRAY, true,
orientation) orientation)
: new BitmapCanvasProvider(bout, format, resolution, BufferedImage.TYPE_BYTE_BINARY, false, : new BitmapCanvasProvider(bout, format, resolution, BufferedImage.TYPE_BYTE_BINARY, false,
orientation); orientation);
gen.generateBarcode(bitmap, msg); gen.generateBarcode(bitmap, msg);
bitmap.finish(); bitmap.finish();
} }
...@@ -157,16 +152,16 @@ public class BarcodeController { ...@@ -157,16 +152,16 @@ public class BarcodeController {
LOGGER.log(Level.SEVERE, ERROR_WHILE_GENERATING_BARCODE, e); LOGGER.log(Level.SEVERE, ERROR_WHILE_GENERATING_BARCODE, e);
throw new ServletException(e); throw new ServletException(e);
} }
} }
*//** /**
* Check the request for the desired output format. * Check the request for the desired output format.
* *
* @param request * @param request
* the request to use * the request to use
* @return MIME type of the desired output format. * @return MIME type of the desired output format.
*//* */
protected String determineFormat(HttpServletRequest request) { protected String determineFormat(HttpServletRequest request) {
String format = request.getParameter(BARCODE_FORMAT); String format = request.getParameter(BARCODE_FORMAT);
format = MimeTypes.expandFormat(format); format = MimeTypes.expandFormat(format);
...@@ -176,14 +171,14 @@ public class BarcodeController { ...@@ -176,14 +171,14 @@ public class BarcodeController {
return format; return format;
} }
*//** /**
* Build an Configuration object from the request. * Build an Configuration object from the request.
* *
* @param request * @param request
* the request to use * the request to use
* @return the newly built COnfiguration object * @return the newly built COnfiguration object
* *
*//* */
protected Configuration buildCfg(HttpServletRequest request) { protected Configuration buildCfg(HttpServletRequest request) {
// Get type // Get type
String type = request.getParameter(BARCODE_TYPE); String type = request.getParameter(BARCODE_TYPE);
...@@ -232,5 +227,5 @@ public class BarcodeController { ...@@ -232,5 +227,5 @@ public class BarcodeController {
} }
return cfg; return cfg;
}*/ }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment