s设备标签打印问题

zyy_db
anthonywj 2 years ago
parent c73e2bf1f2
commit 270410daea

@ -335,7 +335,7 @@ public class DeviceInfoController extends BaseController {
* @return
*/
@AuthRuleAnnotation("")
@PostMapping("/udiwms/inv/deptDevice/printOrder1")
@PostMapping("/udiwms/inv/deptDev/label/print")
public BaseResponse printLabel(@RequestBody DeviceInfoDetailQuery query, HttpServletRequest request, HttpServletResponse response) throws Exception {
List<DeviceInfoVo> list = deviceInfoService.detail(query);
@ -343,7 +343,7 @@ public class DeviceInfoController extends BaseController {
throw new JsonException("未找到该设备,无法生成");
}
DeviceInfoVo obj = list.get(0);
SysPdfTemplateRelevanceLabelEntity sysPdfTemplateRelevanceLabelEntity = systemPDFModuleService.selectByLabelId("5");
SysPdfTemplateRelevanceLabelEntity sysPdfTemplateRelevanceLabelEntity = systemPDFModuleService.selectByLabelId(query.getLabelId() + "");
if (null == sysPdfTemplateRelevanceLabelEntity) {
return ResultVOUtils.error(ResultEnum.DATA_NOT, "所属模块错误");
}
@ -370,6 +370,7 @@ public class DeviceInfoController extends BaseController {
supData.put("supName", obj.getSupName() == null ? ' ' : obj.getSupName());
data.put("data", supData);
String param = JSON.toJSONString(data);
log.error(param);
JasperUtils.jasperReport(request, response, param, filePath + "pdf/template/" + systemPDFTemplateEntity.getPath(), "pdf");
return ResultVOUtils.error(ResultEnum.DATA_NOT, "模板错误");

@ -44,5 +44,11 @@ public class DeviceInfoDetailQuery extends ListPageRequest {
*/
private Long planId;
/**
* ID
*/
private Integer labelId;
}

@ -2,12 +2,14 @@ package com.glxp.api.util;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.export.ooxml.JRDocxExporter;
import net.sf.jasperreports.engine.query.JsonQueryExecuterFactory;
import net.sf.jasperreports.engine.util.JRLoader;
import net.sf.jasperreports.export.SimpleExporterInput;
import net.sf.jasperreports.export.SimpleOutputStreamExporterOutput;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@ -27,6 +29,7 @@ import java.util.Map;
* @author chenqf
* @date 2021-11-10 22:23
*/
@Slf4j
@Component
public class JasperUtils {
private static Logger logger = LoggerFactory.getLogger(JasperUtils.class);
@ -43,7 +46,7 @@ public class JasperUtils {
public static void jasperReport(HttpServletRequest request, HttpServletResponse response, Map<String, Object> data, String jasperResource, String type) throws IOException, JRException {
try {
HashMap<String, Object> map = new HashMap<String, Object>();
logger.error(JSON.toJSONString(data));
log.error(JSON.toJSONString(data));
InputStream is = new ByteArrayInputStream(JSONUtil.toJsonStr(data).getBytes(StandardCharsets.UTF_8));
map.put("JSON_INPUT_STREAM", is); //填充报表数据
map.put(JsonQueryExecuterFactory.JSON_LOCALE, Locale.ENGLISH);
@ -68,14 +71,14 @@ public class JasperUtils {
os.close();
}
} catch (Exception e) {
e.printStackTrace();
log.error(ExceptionUtils.getStackTrace(e));
}
}
public static void jasperReport(HttpServletRequest request, HttpServletResponse response, String data, String jasperResource, String type) throws IOException, JRException {
try {
HashMap<String, Object> map = new HashMap<String, Object>();
logger.error(JSON.toJSONString(data));
log.error(JSON.toJSONString(data));
InputStream is = new ByteArrayInputStream(data.getBytes("UTF-8"));
map.put("JSON_INPUT_STREAM", is); //填充报表数据
map.put(JsonQueryExecuterFactory.JSON_LOCALE, Locale.ENGLISH);
@ -100,8 +103,7 @@ public class JasperUtils {
os.close();
}
} catch (Exception e) {
e.printStackTrace();
log.error(ExceptionUtils.getStackTrace(e));
}
}
@ -128,9 +130,7 @@ public class JasperUtils {
JasperExportManager.exportReportToPdfFile(jasperPrint, filePath);
} catch (Exception e) {
e.printStackTrace();
log.error(ExceptionUtils.getStackTrace(e));
}
}

Loading…
Cancel
Save