@@ -47,23 +47,23 @@ public class RegisterServiceImpl implements PrintService {
@Override
public LexMarkResultDTO < LexMarkResultDTO . Param > printImage ( JSONObject data , String template , int width , int height , String saveDir ) {
if ( height < = 0 ) {
if ( height < = 0 ) {
width = FIXED_WIDTH ;
}
if ( StringUtils . isEmpty ( printerConfig . getTimeType ( ) ) ) {
if ( StringUtils . isEmpty ( printerConfig . getTimeType ( ) ) ) {
throw new RRException ( " 获取打印时间格式出错: " + printerConfig . getTimeType ( ) ) ;
}
if ( StringUtils. isEmpty( printerConfig. getTerminalNumber( ) ) ) {
throw new RRException ( " 获取终端号出错: " + printerConfig. getTerminalNumber( ) ) ;
}
// if ( StringUtils. isEmpty( printerConfig. getTerminalNumber())) {
// throw new RRException("获取终端号出错:" + printerConfig. getTerminalNumber()) ;
// }
// 强行设置终端号
data. put ( " terminalNumber" , printerConfig. getTerminalNumber( ) ) ;
// data.put(" terminalNumber", printerConfig. getTerminalNumber()) ;
// 强行设置终端号和打印时间
SimpleDateFormat sdf = new SimpleDateFormat ( printerConfig . getTimeType ( ) ) ;
String formattedDate = sdf . format ( new Date ( ) ) ;
String formattedDate = sdf . format ( new Date ( ) ) ;
data . put ( " printTime " , formattedDate ) ;
// 获取模板
@@ -84,25 +84,25 @@ public class RegisterServiceImpl implements PrintService {
JSONObject itemEntity = ( JSONObject ) item ;
String projectName = String . valueOf ( itemEntity . get ( " name " ) ) ;
int length = projectName . length ( ) ;
int count = ( int ) Math . ceil ( ( double ) length / singleLineMaxLength ) ;
int count = ( int ) Math . ceil ( ( double ) length / singleLineMaxLength ) ;
dinyHeight + = count * singleLineHeight ;
}
// 计算是否有门诊号
String outpatientNumber = data . getString ( " outpatientNumber " ) ;
if ( ! StringUtils . isEmpty ( outpatientNumber ) ) {
if ( ! StringUtils . isEmpty ( outpatientNumber ) ) {
dinyHeight + = 35 ;
}
// 计算是否有就诊医生
String doctor = data . getString ( " doctor " ) ;
if ( ! StringUtils . isEmpty ( doctor ) ) {
if ( ! StringUtils . isEmpty ( doctor ) ) {
dinyHeight + = 35 ;
}
// 计算是否有就诊科室
String department = data . getString ( " department " ) ;
if ( ! StringUtils . isEmpty ( department ) ) {
if ( ! StringUtils . isEmpty ( department ) ) {
dinyHeight + = 35 ;
}
@@ -112,9 +112,9 @@ public class RegisterServiceImpl implements PrintService {
this . getStatus ( ) ;
StringBuilder filePath = new StringBuilder ( saveDir ) ;
// 校验是否选中了模板,如果没选中模板的话则不需要另外生成了
if ( ! StringUtils . isEmpty ( templateName ) & & ! StringUtils . isEmpty ( saveDir ) ) {
if ( ! StringUtils . isEmpty ( templateName ) & & ! StringUtils . isEmpty ( saveDir ) ) {
byte [ ] image = new TemplateUtils ( ) . generateReceiptImage ( data , templateName , width , height , filePath ) ;
} else {
} else {
throw new RRException ( " 模板渲染错误 " ) ;
}
@@ -125,7 +125,7 @@ public class RegisterServiceImpl implements PrintService {
deletePathList [ 0 ] = filePath . toString ( ) ;
String [ ] filePathList = new String [ numPieces ] ;
// 对图片进行分块处理,当前台式打印机最大参数配置 宽度690, 高度1200
if ( height > MAX_HEIGHT ) {
if ( height > MAX_HEIGHT ) {
try {
// 读取输入图片
BufferedImage originalImage = ImageIO . read ( new File ( filePath . toString ( ) ) ) ;
@@ -150,7 +150,7 @@ public class RegisterServiceImpl implements PrintService {
log . error ( " 模板切割失败 " ) ;
e . printStackTrace ( ) ;
}
} else {
} else {
filePathList [ 0 ] = " LOGO1= " + filePath ;
}
@@ -172,7 +172,7 @@ public class RegisterServiceImpl implements PrintService {
LexMarkResultDTO < LexMarkResultDTO . Param > paramLexMarkResultDTO = thirdService . callDevice ( lexMarkDTO , LexMarkResultDTO . Param . class ) ;
for ( String path : deletePathList ) {
if ( path ! = null & & ! path . isEmpty ( ) ) {
if ( path ! = null & & ! path . isEmpty ( ) ) {
File file = new File ( path ) ;
// 检查文件是否存在
if ( file . exists ( ) ) {
@@ -200,7 +200,7 @@ public class RegisterServiceImpl implements PrintService {
lexMarkDTO . setPluginMethod ( " getInfo " ) ;
// lexMarkDTO.setMethodType(0);
LexMarkResultDTO < PrinterStatus > status = thirdService . callDevice ( lexMarkDTO , PrinterStatus . class ) ;
if ( status . getResult ( ) ! = 0 ) {
if ( status . getResult ( ) ! = 0 ) {
thirdService . open ( " ReceiptPrinter " , 1 ) ;
status = thirdService . callDevice ( lexMarkDTO , PrinterStatus . class ) ;
}
@@ -212,16 +212,16 @@ public class RegisterServiceImpl implements PrintService {
throw new RRException ( " 获取打印机纸张状态出问题 " ) ;
}
String [ ] papers = stPaperEx . split ( " \\ | " ) ;
if ( papers . length < 1 ) {
if ( papers . length < 1 ) {
throw new RRException ( " 打印机纸盒数量不对 " ) ;
}
String paperStatus = papers [ 0 ] ;
if ( ! ( paperStatus . equals ( MS439PaperStatusEnum . PAPERFULL . getPrintCode ( ) ) | | paperStatus . equals ( MS439PaperStatusEnum . PAPERLOW . getPrintCode ( ) ) ) ) {
if ( ! ( paperStatus . equals ( MS439PaperStatusEnum . PAPERFULL . getPrintCode ( ) ) | | paperStatus . equals ( MS439PaperStatusEnum . PAPERLOW . getPrintCode ( ) ) ) ) {
throw new RRException ( 500 , paperStatus ) ;
}
// 校验打印机是否正常,除了HEALTHY都抛异常
if ( ! ms439 . getStDeviceStatus ( ) . equals ( MS439DeviceStatusEnum . HEALTHY . getPrintCode ( ) ) ) {
if ( ! ms439 . getStDeviceStatus ( ) . equals ( MS439DeviceStatusEnum . HEALTHY . getPrintCode ( ) ) ) {
throw new RRException ( 500 , ms439 . getStDeviceStatus ( ) ) ;
}
@@ -231,13 +231,13 @@ public class RegisterServiceImpl implements PrintService {
}
// 校验磁带 满或者少才放行
if ( false & & ! ( ms439 . getStToner ( ) . equals ( MS439TonerStatusEnum . TONERFULL . getPrintCode ( ) ) | | ms439 . getStToner ( ) . equals ( MS439TonerStatusEnum . TONERLOW . getPrintCode ( ) ) ) ) {
if ( false & & ! ( ms439 . getStToner ( ) . equals ( MS439TonerStatusEnum . TONERFULL . getPrintCode ( ) ) | | ms439 . getStToner ( ) . equals ( MS439TonerStatusEnum . TONERLOW . getPrintCode ( ) ) ) ) {
throw new RRException ( 500 , ms439 . getStToner ( ) ) ;
}
// 校验墨盒 满或者少才放行,当前获取为未知
if ( false & & ! ( ms439 . getStInk ( ) . equals ( MS439InkStatusEnum . INKFULL . getPrintCode ( ) ) | | ms439 . getStInk ( ) . equals ( MS439InkStatusEnum . INKLOW . getPrintCode ( ) )
| | ms439 . getStInk ( ) . equals ( MS439InkStatusEnum . INKUNKNOWN . getPrintCode ( ) ) ) ) {
if ( false & & ! ( ms439 . getStInk ( ) . equals ( MS439InkStatusEnum . INKFULL . getPrintCode ( ) ) | | ms439 . getStInk ( ) . equals ( MS439InkStatusEnum . INKLOW . getPrintCode ( ) )
| | ms439 . getStInk ( ) . equals ( MS439InkStatusEnum . INKUNKNOWN . getPrintCode ( ) ) ) ) {
throw new RRException ( 500 , ms439 . getStInk ( ) ) ;
}