package com.jltour.common.util;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.color.ColorSpace;
import java.awt.geom.AffineTransform;
import java.awt.geom.Line2D;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.awt.image.ColorConvertOp;
import java.awt.image.DataBufferByte;
import java.awt.image.RenderedImage;
import java.awt.image.WritableRaster;
import java.awt.image.renderable.ParameterBlock;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import javax.imageio.ImageIO;
import javax.media.jai.Histogram;
import javax.media.jai.JAI;
import javax.media.jai.PlanarImage;
import javax.media.jai.RenderedOp;
import org.apache.struts2.ServletActionContext;
import org.krysalis.barcode4j.impl.code39.Code39Bean;
import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider;
import org.krysalis.barcode4j.tools.UnitConv;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
import com.jltour.authority.auto.beans.User;
import com.jltour.common.constant.OptionType;
import com.jltour.common.exception.Java91Exception;
import com.jltour.common.framework.Framework;
import com.jltour.common.framework.Java91Config;
import com.jltour.common.manager.FtpManager;
import com.jltour.common.manager.OptionManager;
import com.jltour.common.manager.fax.HttpRequester;
import com.jltour.common.manager.fax.HttpRespons;
import com.jltour.common.manager.interfaces.FaxManager;
import com.jltour.reserve.aManual.dao.ReserveDao;
import com.jltour.reserve.auto.beans.Dailyauditstatus;
import com.jltour.reserve.auto.beans.Order;
import com.jltour.reserve.auto.beans.Orderitem;
import com.jltour.reserve.auto.beans.Orderitemdate;
import com.jltour.reserve.auto.beans.Orderotherfees;
import com.jltour.reserve.auto.beans.Orderroomtypebean;
import com.jltour.reserve.auto.beans.Orderroomtypeprice;
import com.jltour.reserve.auto.dao.OrderDao;
import com.jltour.reserve.auto.dao.OrderroomtypepriceDao;
import com.sun.image.codec.jpeg.ImageFormatException;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
import com.sun.media.jai.codec.BMPEncodeParam;
import com.sun.media.jai.codec.FileSeekableStream;
import com.sun.media.jai.codec.ImageCodec;
import com.sun.media.jai.codec.ImageDecoder;
import com.sun.media.jai.codec.ImageEncoder;
import com.sun.media.jai.codec.JPEGEncodeParam;
import com.sun.media.jai.codec.SeekableStream;
import com.sun.media.jai.codec.TIFFDecodeParam;
import com.sun.media.jai.codec.TIFFEncodeParam;
import com.sun.media.jai.codecimpl.BMPCodec;
import com.sun.media.jai.codecimpl.BMPImageEncoder;
/**
* 传真图片工具类
*
* @author huangjin
*
*/
public class ImageFaxUtil {
// private static String bascDec ="D:\\reportXmlFile\\ok\\" ;
private static String baseHeadFile = "baseHead.bmp";//baseHeadMember.bmp
private static String baseHeadMemberFile = "baseHeadMember.bmp";
private static String baseHeadDayFile = "baseHeadDay.bmp";
private static String baseBottomFile = "baseBottom.bmp";
private static final int imageWidth = 800;// 传真文件宽度
private static final Font fontPage = new Font("宋体", Font.BOLD, 14);// 当前页面的字体设置
//private static final Font fontPage = new Font("黑体", Font.PLAIN, 12);// 当前页面的字体设置
private static String jltourPhoto = "86-755-33397777";
private static final String jltourFax = "86-755-33389800";
private static final int linHieght = 25;
//创建订单传真图片-供应商
public static String createOrderFaxPictureBySupplier(String bascDec, String barcode, String resultSrc, User user, Order order, List orderroomtypebeanList, List orderotherfeesList,
String orderType,String isprotocol) {
if (null == user || null == order || null == orderroomtypebeanList || orderroomtypebeanList.size()<=0 || null == orderType || orderType.length()<=0)
return null;
//System.out.println("33333333333333333333333333333333333333333333333333333333333333333333333333");
try {
if(null == isprotocol || isprotocol.length()<=0){
isprotocol="8";
}
String pers = order.getCheckinpersons();
//String pers = "保钓委执委曾健成说,他们首选是从香港出发前往钓鱼岛宣示主权,但由于担心受到阻挠,因此,他们同时也拟定从台湾出发的方案。但最后从哪里出发,无明确说明。";
int perno = pers.length()/45+1;
BufferedImage imageHead = new BufferedImage(imageWidth, 250+(perno-1)*15+10, BufferedImage.TYPE_INT_RGB);
String barCodeDic= ImageFaxUtil.createBarcodeImage(bascDec, barcode);//条形码图片
File logofile = new File(Framework.servletRealPath+"faxFile"+File.separator+ "logo.jpg");
Image logoImage = javax.imageio.ImageIO.read(logofile); // 读取jpg等图片文件
InputStream barCodeStream = new FileInputStream(bascDec + barCodeDic);
BufferedImage barCodeImage = ImageIO.read(barCodeStream);
Graphics graphics = imageHead.getGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, imageWidth, 250+(perno-1)*15+10);
graphics.setColor(Color.BLACK);
graphics.drawImage(logoImage, 75, 30, null);
graphics.drawImage(barCodeImage, 560, 30, null);
graphics.setFont(fontPage);// 设置当前图片全局字体
graphics.drawLine(20, 129, 800, 129);//画线
//黑体 隶书 华文楷体
graphics.setFont(new Font("宋体",Font.BOLD, 15));//普通字体
graphics.drawString(CommonUtil.getDefault(order.getHotelname())+" 订房部", 75, 185);// 酒店的名字
//graphics.setFont(fontPage);// 设置当前图片全局字体
graphics.drawLine(45, 190, 295, 190);//画线
graphics.drawString(order.getHotelname(), 110, 205);
graphics.drawLine(45, 210, 280, 210);//画线
String pricingtype="";
if(order.getPricingtype().intValue() == 11 ){
pricingtype="客人前台现付";
}else{
if(order.getOrherhang().intValue()==1){
pricingtype="房费挂帐,杂费可挂帐";
}else{
pricingtype="房费挂帐,杂费客人自理";
}
}
graphics.drawString(pricingtype, 110, 230);
graphics.setFont(new Font("宋体",Font.PLAIN, 13));//普通字体
graphics.drawString("深圳市捷旅国际旅行社有限公司 www.jl-tour.com", 100, 110);
graphics.drawString("发送人/工号:", 50, 126);
graphics.drawString(user.getRealname()+"/"+user.getUsercd(), 135, 126);
graphics.drawString("电话:", 200, 126);
graphics.drawString(jltourPhoto, 236, 126);
graphics.drawString("传真:", 370, 126);
graphics.drawString(jltourFax, 402, 126);
graphics.drawString("发送时间:", 530, 126);
graphics.drawString(CommonUtil.getDateString(new java.util.Date(), "yyyy-MM-dd HH:mm"), 590, 126);
graphics.drawString("致:", 45, 185);
graphics.drawString("酒店名称:", 45, 205);// 酒店的名字
graphics.drawString("结算方式:", 45, 230);
graphics.drawString("客人姓名:", 45, 250);
graphics.setFont(new Font("宋体", Font.BOLD, 14));
graphics.drawLine(45, 235, 295, 235);//画线
int noys=250;
int test=0;
int i=0;
if(perno>1){
while(i<perno){
test = (((i)*45+45)>=pers.length())?pers.length():((i)*45+45-1);
graphics.drawString(pers.substring((i)*45,test), 105, noys);
noys = noys+15;
i++;
}
}else{
graphics.drawString(pers, 105, 250);
}
graphics.drawString("订单编号:", 600, 152);
graphics.drawString(order.getOrdercd(), 665, 152);
Font fontTitle = new Font("黑体", Font.BOLD, 20);
graphics.setFont(fontTitle);
graphics.drawString(orderType, 235, 155);
//BufferedImage bg_src = ImageFaxUtil.createBaseHeadBufImage(bascDec, ImageFaxUtil.createBarcodeImage(bascDec, barcode), user.getUsercd()+"/"+user.getRealname(), orderType, order);
BufferedImage bi_pricesrc = ImageFaxUtil.createImagePrice(orderroomtypebeanList, orderotherfeesList, orderType, order,isprotocol,"sup");
//File logofile = new File(Framework.servletRealPath+"faxFile\\"+ baseBottomFile);
//Image logo_src = javax.imageio.ImageIO.read(logofile); // 读取最下面的文件
BufferedImage bottom =ImageFaxUtil.createImageBottom();
int bg_width = imageHead.getWidth(null);
int bg_height = imageHead.getHeight(null);
int logo_width = bottom.getWidth(null);
int logo_height = bottom.getHeight(null);
int bi_width = bi_pricesrc.getWidth(null);
int bi_height = bi_pricesrc.getHeight(null);
BufferedImage imgage = new BufferedImage(imageWidth, bg_height + logo_height + bi_height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = imgage.createGraphics();
g2d.drawImage(imageHead, 0, 0, bg_width, bg_height, null);
// 组合价格
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 1.0f)); // 透明度设置开始
g2d.drawImage(bi_pricesrc, 0, bg_height, bi_width, bi_height, null);
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); // 透明度设置
// 结束
// 组合下面
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 1.0f)); // 透明度设置开始
g2d.drawImage(bottom, 0, bg_height + bi_height, logo_width, logo_height, null);
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); // 透明度设置
// 结束
//图片黑白
//ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
//ColorConvertOp op = new ColorConvertOp(cs, null);
// imgage = op.filter(imgage, null);
FileOutputStream out = new FileOutputStream(Framework.servletRealPath+Java91Config.getFaxImageTempPath()+File.separator + resultSrc);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(imgage);
out.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
}
return resultSrc;
}
//生成条形码文件 返回对应的生成的条形码文件的图片全称
public static String createBarcodeImage(String bascDec, String content) throws IOException {
String result = "";
Code39Bean bean = new Code39Bean();
final int dpi = 150;
bean.setModuleWidth(UnitConv.in2mm(1.0f / dpi)); // makes the narrow
// bar
bean.setHeight(10);
bean.setWideFactor(3);
bean.doQuietZone(false);
File outputFile = new File(bascDec + content + "barcode.jpg");
OutputStream out = new FileOutputStream(outputFile);
try {
BitmapCanvasProvider canvas = new BitmapCanvasProvider(out, "image/jpeg", dpi, BufferedImage.TYPE_BYTE_BINARY, false, 0);
bean.generateBarcode(canvas, content);
canvas.finish();
result = content + "barcode.jpg";
} finally {
out.close();
}
return result;
}
//供应商 订单底图
public static BufferedImage createImageBottom() {
BufferedImage image = new BufferedImage(imageWidth, 180, BufferedImage.TYPE_INT_RGB);
Graphics graphics = image.getGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, imageWidth, 210);
graphics.setColor(Color.BLACK);
graphics.setFont(fontPage);// 设置当前图片全局字体
graphics.drawLine(55, 10, 760, 10);//画线
graphics.drawString("酒店确认栏", 55, 30);// photo
graphics.drawString("□ 本单确认", 85, 50);// photo
graphics.drawString("□ 本单不确认及原因", 205, 50);//
graphics.drawLine(345, 60, 760, 60);//画线
graphics.drawString("确认号:", 85, 80);// photo
graphics.drawLine(125, 90, 760, 90);//画线
graphics.drawString("签名栏:", 85, 120);// photo
graphics.drawLine(125, 130, 760, 130);//画线
graphics.drawString("酒店备注:", 85, 160);// photo
graphics.drawLine(125, 169, 760, 169);//画线
return image;
}
public static BufferedImage createImageBottomByCustomer() {
BufferedImage image = new BufferedImage(imageWidth, 160, BufferedImage.TYPE_INT_RGB);
Graphics graphics = image.getGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, imageWidth, 210);
graphics.setColor(Color.BLACK);
graphics.setFont(fontPage);// 设置当前图片全局字体
graphics.drawLine(15, 0, 800, 0);//画线
return image;
}
//供应商 订单传真 价格
public static BufferedImage createImagePrice(List orderroomtypebeanList, List orderotherfeesList, String orderType, Order order,String isprotocol,String cus_suptype) {
int noCount=0;
double countPirce=0;
if (null != orderroomtypebeanList) {
Orderroomtypebean orderroomtypebean;
int priceRoomLength=0;
String showpricenotes="";
for (int i = 0; i < orderroomtypebeanList.size(); i++) {
orderroomtypebean = (Orderroomtypebean) orderroomtypebeanList.get(i);
if("1".equals(isprotocol)){
orderroomtypebean.setPricenotebaseprice("协议价");
showpricenotes="协议价";
orderroomtypebean.setCreateby("协议价");
}else{
if(orderroomtypebean.getPricingtype()==11){
if("sup".equals(cus_suptype)){
if(null==orderroomtypebean.getIsequalsaleprice() || orderroomtypebean.getIsequalsaleprice()!=1){
showpricenotes=orderroomtypebean.getPricenotesaleprice();
}else{
showpricenotes=""+orderroomtypebean.getAvasaleprice();
}
orderroomtypebean.setPricenotebaseprice(showpricenotes);
orderroomtypebean.setCreateby(""+orderroomtypebean.getAvasaleprice().intValue()*orderroomtypebean.getDays()*orderroomtypebean.getRoomqty());
countPirce = countPirce + (int) orderroomtypebean.getAvasaleprice().intValue() * orderroomtypebean.getDays() * orderroomtypebean.getRoomqty();
}else if("cus".equals(cus_suptype)){
if(null==orderroomtypebean.getIsequalsaleprice() || orderroomtypebean.getIsequalsaleprice()!=1){
showpricenotes=orderroomtypebean.getPricenotesaleprice()+" 返"+((int)(orderroomtypebean.getAvasaleprice().doubleValue()-orderroomtypebean.getAvapreeprice().doubleValue()));
}else{
showpricenotes=""+orderroomtypebean.getAvasaleprice()+" 返"+((int)(orderroomtypebean.getAvasaleprice().doubleValue()-orderroomtypebean.getAvapreeprice().doubleValue()));
}
orderroomtypebean.setPricenotebaseprice(showpricenotes);
orderroomtypebean.setCreateby(""+orderroomtypebean.getAvasaleprice().intValue()*orderroomtypebean.getDays()*orderroomtypebean.getRoomqty());
countPirce = countPirce + (int) orderroomtypebean.getAvasaleprice().intValue() * orderroomtypebean.getDays() * orderroomtypebean.getRoomqty();
}
}else{
if("sup".equals(cus_suptype)){
if(null==orderroomtypebean.getIsequalbaseprice() || orderroomtypebean.getIsequalbaseprice()!=1){
showpricenotes=orderroomtypebean.getPricenotebaseprice();
}else{
showpricenotes=""+orderroomtypebean.getAvabaseprice();
}
orderroomtypebean.setPricenotebaseprice(showpricenotes);
orderroomtypebean.setCreateby(""+orderroomtypebean.getAvabaseprice().intValue()*orderroomtypebean.getDays()*orderroomtypebean.getRoomqty());
countPirce = countPirce + (int) orderroomtypebean.getAvabaseprice().intValue()*orderroomtypebean.getDays() * orderroomtypebean.getRoomqty();
}else if("cus".equals(cus_suptype)){
if(null==orderroomtypebean.getIsequalpreeprice() || orderroomtypebean.getIsequalpreeprice()!=1){
showpricenotes=orderroomtypebean.getPricenotepreeprice();
}else{
showpricenotes=""+orderroomtypebean.getAvapreeprice();
}
orderroomtypebean.setPricenotebaseprice(showpricenotes);
orderroomtypebean.setCreateby(""+orderroomtypebean.getAvapreeprice().intValue()*orderroomtypebean.getDays()*orderroomtypebean.getRoomqty());
countPirce = countPirce + (int) orderroomtypebean.getAvapreeprice().intValue()*orderroomtypebean.getDays() * orderroomtypebean.getRoomqty();
}
}
}
if(orderroomtypebean.getRoomtypenameratetype().length()>showpricenotes.length()){
priceRoomLength= orderroomtypebean.getRoomtypenameratetype().length();
}else{
priceRoomLength=showpricenotes.length();
}
noCount = noCount+ (priceRoomLength/11+1)*linHieght;
}
}
String hotelRemark = "";
if("sup".equals(cus_suptype)){
hotelRemark= order.getHotelremark();
}else{
hotelRemark=order.getMemberremark();
}
int remarkNos = hotelRemark.length()/42+1;
int imageHeight = 15 + orderroomtypebeanList.size() * linHieght + orderotherfeesList.size() * linHieght + linHieght + 10+55+(remarkNos-1)*20+noCount;
BufferedImage image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
Graphics graphicsPrice = image.getGraphics();
Font fontHead = new Font("宋体", Font.BOLD, 14);// 头部字
graphicsPrice.setFont(fontHead);
graphicsPrice.setColor(Color.WHITE);
graphicsPrice.fillRect(0, 0, imageWidth, imageHeight);
graphicsPrice.setColor(Color.BLACK);
graphicsPrice.drawLine(42, 0, 760, 0);//画线
graphicsPrice.drawString("类型", 45, 15);
graphicsPrice.drawString("内容", 150, 15);
graphicsPrice.drawString("入住日期", 242, 15);
graphicsPrice.drawString("退房日期", 310, 15);
graphicsPrice.drawString("晚数", 380, 15);
graphicsPrice.drawString("间数", 420, 15);
graphicsPrice.drawString("含早情况", 460, 15);
if (order.getPricingtype() == 11) {// 现付
graphicsPrice.drawString("现付价", 590, 15);
} else {
graphicsPrice.drawString("挂帐价", 590, 15);
}
graphicsPrice.drawString("小计", 715, 15);
graphicsPrice.drawLine(42, 20, 760, 20);//画线
Font fontContent = new Font("宋体", Font.PLAIN, 14);// 头部字
graphicsPrice.setFont(fontContent);
int noY = 15;// 当前开始写的y坐标
int priceRoomLength=0;//最长的字体长度
int rowLength=1;//行数
String latestarrivaltime="";//到店时间
if (null != orderroomtypebeanList) {
Orderroomtypebean orderroomtypebean;
for (int i = 0; i < orderroomtypebeanList.size(); i++) {
orderroomtypebean = (Orderroomtypebean) orderroomtypebeanList.get(i);
noY = noY + linHieght;
//orderroomtypebean.setRoomtypenameratetype("标单(含单早)K JFDKJF");//房型
//orderroomtypebean.setRoomtypenameratetype("李停,张莫大李世大刘新好不成因为莫成好李成莫金大中胡涛水");//房型
//orderroomtypebean.setPricenotebaseprice("9月4日490,9月5日500,9月6日510");//价格字段
/*int roomtypeX=90;
if(orderroomtypebean.getRoomtypenameratetype().length()>11){
//orderroomtypebean.setRoomtypenameratetype(orderroomtypebean.getRoomtypenameratetype().substring(0,11));
}
if(orderroomtypebean.getRoomtypenameratetype().length()<4){
roomtypeX=120;
}else if(orderroomtypebean.getRoomtypenameratetype().length()<8){
roomtypeX=100;
}else {
roomtypeX=90;
}
*/
orderType=orderType.replace("预订", "");
graphicsPrice.drawString(orderType.substring(0,orderType.length()-1), 46, noY);
graphicsPrice.drawString(CommonUtil.getDateString(orderroomtypebean.getCheckindate(), "M月d日"),245, noY);
graphicsPrice.drawString(CommonUtil.getDateString(orderroomtypebean.getCheckoutdate(), "M月d日"), 320, noY);
graphicsPrice.drawString(orderroomtypebean.getDays()+"晚", 386, noY);
graphicsPrice.drawString(orderroomtypebean.getRoomqty()+"间 ", 425, noY);
graphicsPrice.drawString(orderroomtypebean.getCreateby(), 710, noY);
/*
Map map=new HashMap();
OrderroomtypepriceDao orderroomtypepriceDao=(OrderroomtypepriceDao) Framework.getDaoFactory().getBean("orderroomtypepriceDao");
int breakfast=10;
if(orderroomtypebean.getServicerate().intValue()==1){//该BEAN的所有PRICE 都为是一样的。
breakfast=orderroomtypebean.getIncludebreakfastqty2();
}else{
map.put("orderroomtypebeanid", orderroomtypebean.getOrderroomtypebeanid());
map.put("sortString", "includebreakfastqty2,night");
List pricelist=orderroomtypepriceDao.queryOrderroomtypeprices(map);
Orderroomtypeprice price=null;
for(int n=0;n<pricelist.size();n++){
price=(Orderroomtypeprice)pricelist.get(n);
}
}
*/
graphicsPrice.drawString(OptionManager.getNameByCode(OptionType.inbreakfast, "" + orderroomtypebean.getIncludebreakfastqty2()), 476, noY);
//graphicsPrice.drawString(orderroomtypebean, 476, noY);
//latestarrivaltime = orderroomtypebean.getLatestarrivaltime();
//graphicsPrice.drawString(orderroomtypebean.getLatestarrivaltime(), 450, noY);
/*
* if(order.getPricingtype()==11){//现付
* if(orderroomtypebean.getIsequalsaleprice()==1){
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getAvasaleprice()),
* 675, noY); }else{
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getPricenotesaleprice()),
* 675, noY); }
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getAvasaleprice()*orderroomtypebean.getDays()*orderroomtypebean.getRoomqty()),
* 745, noY); }else{
* if(orderroomtypebean.getIsequalbaseprice()==1){
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getAvabaseprice()),
* 675, noY); }else{
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getPricenotebaseprice()),
* 675, noY); }
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getAvabaseprice()*orderroomtypebean.getDays()*orderroomtypebean.getRoomqty()),
* 745, noY); }
*/
/*
if("1".equals(isprotocol)){
graphicsPrice.drawString("协议价", 535, noY);//现付价
graphicsPrice.drawString("协议价", 680, noY);//现付价
}else{
if (order.getPricingtype().intValue() == 11) {// 现付
graphicsPrice.drawString("RMB "+(int) orderroomtypebean.getAvasaleprice().intValue(), 530, noY);//现付价
graphicsPrice.drawString(CommonUtil.getDefault((int) orderroomtypebean.getAvasaleprice().intValue() * orderroomtypebean.getDays()* orderroomtypebean.getRoomqty()), 700, noY);//现付合计
countPirce = countPirce + (int) orderroomtypebean.getAvasaleprice().intValue() * orderroomtypebean.getDays() * orderroomtypebean.getRoomqty();
} else {
graphicsPrice.drawString(order.getCurrency()+" "+(int) orderroomtypebean.getAvabaseprice().intValue(), 530, noY);//底价
graphicsPrice.drawString(CommonUtil.getDefault((int) orderroomtypebean.getAvabaseprice().intValue() * orderroomtypebean.getDays()* orderroomtypebean.getRoomqty()),700, noY);
countPirce = countPirce + (int) orderroomtypebean.getAvabaseprice().intValue() * orderroomtypebean.getDays() * orderroomtypebean.getRoomqty();
}
}*/
if(orderroomtypebean.getRoomtypenameratetype().length()>orderroomtypebean.getPricenotebaseprice().length()){
priceRoomLength= orderroomtypebean.getRoomtypenameratetype().length();
}else{
priceRoomLength=orderroomtypebean.getPricenotebaseprice().length();
}
int rows =0;
String [] showroomtypes=StringsUtil.splitByindex(orderroomtypebean.getRoomtypenameratetype(),10);
String [] showprices=StringsUtil.splitByindex(orderroomtypebean.getPricenotebaseprice(),23);
if(showroomtypes.length>showprices.length){
rows=showroomtypes.length;
}else{
rows=showprices.length;
}
for(int jj=0;jj<rows;jj++){
if(jj<=showroomtypes.length-1){
if(showroomtypes.length==1 && showroomtypes[jj].length()<3){
graphicsPrice.drawString(showroomtypes[jj], 130, noY);
}else if(showroomtypes.length==1 && showroomtypes[jj].length()<6){
graphicsPrice.drawString(showroomtypes[jj], 110, noY);
}else{
graphicsPrice.drawString(showroomtypes[jj], 90, noY);
}
}
if(jj<=showprices.length-1){
if(showprices.length==1 && showprices[jj].length()<7){
graphicsPrice.drawString(showprices[jj], 580, noY);
}else if(showprices.length==1 && showprices[jj].length()<14){
graphicsPrice.drawString(showprices[jj], 550, noY);
}else{
graphicsPrice.drawString(showprices[jj], 530, noY);
}
}
if(jj==rows-1){
}else{
noY=noY+linHieght;
}
}
graphicsPrice.drawLine(42, noY+5, 760, noY+5);//画线
}
}
//画竖线
graphicsPrice.drawLine(240, 0, 240, noY+5);//入住
graphicsPrice.drawLine(305, 0, 305, noY+5);//退房日期
graphicsPrice.drawLine(375, 0, 375, noY+5);//晚数
graphicsPrice.drawLine(415, 0, 415, noY+5);//间数
graphicsPrice.drawLine(455, 0, 455, noY+5);//晚数
double sumprice = 0;
graphicsPrice.setFont(fontContent);
if (null != orderotherfeesList) {
Orderotherfees orderotherfees;
for (int i = 0; i < orderotherfeesList.size(); i++) {
orderotherfees = (Orderotherfees) orderotherfeesList.get(i);
sumprice = sumprice + orderotherfees.getTotalamount();
String otherfeeString="";
String begindates="";
String enddates="";
String dates="";
begindates=CommonUtil.getDateString(orderotherfees.getBegindate(), "M月d日");
if(null==orderotherfees.getEnddate()){
dates=begindates;
}else{
enddates=CommonUtil.getDateString(orderotherfees.getEnddate(), "M月d日");
dates=begindates+"~"+enddates;
}
otherfeeString=otherfeeString+dates;
if (orderotherfees.getFeetype().intValue() == 2) {//早餐
otherfeeString=otherfeeString+" 加"+OptionManager.getNameByCode(OptionType.breaktype, "" + orderotherfees.getBreakfasttype())+" ";
} else {//加床
otherfeeString=otherfeeString+" 加床 ";
}
//otherfeeString=otherfeeString+order.getCurrency()+" "+orderotherfees.getBaseprice()+" * "+orderotherfees.getAmount()+" 份 ";
if(null!=orderType && orderType.length()>2){
orderType=orderType.substring(0,orderType.length()-1);
}
noY = noY + linHieght;
graphicsPrice.drawString(orderType, 45, noY);
graphicsPrice.drawString(otherfeeString, 111, noY);
graphicsPrice.drawString(order.getCurrency()+" "+orderotherfees.getBaseprice()+" * "+orderotherfees.getAmount()+" 份 ", 535, noY);
graphicsPrice.drawString(CommonUtil.getDefault(orderotherfees.getCompanyid()), 700, noY);
graphicsPrice.drawLine(42, noY+5, 760, noY+5);//画线
}
}
if("1".equals(isprotocol)){
graphicsPrice.drawString("协议价", 710, noY + linHieght);
}else{
graphicsPrice.drawString(countPirce + sumprice + "", 700, noY + linHieght);
}
graphicsPrice.drawString("总计("+order.getCurrency()+"):", 580, noY + linHieght);
//下面信息
graphicsPrice.setFont(fontHead);
graphicsPrice.drawString("到店时间:", 40, noY+linHieght+linHieght);
graphicsPrice.drawString(latestarrivaltime, 110, noY+linHieght+linHieght);
if("sup".equals(cus_suptype)){
graphicsPrice.drawString("确认号:", 170, noY+linHieght+linHieght);
graphicsPrice.drawString(null==order.getConfirmno()?"":order.getConfirmno(), 225, noY+linHieght+linHieght);
}
graphicsPrice.drawString("备注信息:", 40, noY+linHieght+linHieght+20);
//graphicsPrice.drawString(order.getHotelremark(), 110, noY+linHieght+linHieght+20);//备注信息
if(remarkNos>1){
int rnoy = noY+linHieght+linHieght+20;
int i=0;
while(i<=remarkNos-1){
graphicsPrice.drawString(hotelRemark.substring(i*43,(i*43+43)>=hotelRemark.length()?hotelRemark.length():(i*43+43)), 110, rnoy);//备注信息
graphicsPrice.drawLine(110, rnoy+5, 760, rnoy+5);//横线
rnoy+=20;
i++;
}
}else{
graphicsPrice.drawString(hotelRemark, 110, noY+linHieght+linHieght+20);//备注信息
graphicsPrice.drawLine(110, noY+linHieght+linHieght+20+5, 760, noY+linHieght+linHieght+20+5);//横线
}
//画竖线
graphicsPrice.drawLine(85, 0, 85, noY+5);//房型
graphicsPrice.drawLine(42, 0, 42, noY+linHieght+5);//画开始线
graphicsPrice.drawLine(525, 0, 525, noY+5);//含早情况
graphicsPrice.drawLine(695, 0, 695, noY+linHieght+5);//结算价
graphicsPrice.drawLine(760, 0, 760, noY+linHieght+5);//画结束线
graphicsPrice.drawLine(42, noY+linHieght+5, 760, noY+linHieght+5);//最后横线
return image;
}
public static String createTiffImageByFileName(String filepath) throws Java91Exception{
String filepath_tif="";
if(null != filepath && filepath.length()>0){
String filepath_tiff = filepath.substring(0,filepath.lastIndexOf("."))+".tif";
try{
String filename_jpg= filepath.substring(filepath.lastIndexOf(File.separator)+1,filepath.length());
String filename_tif = filepath_tiff.substring(filepath_tiff.lastIndexOf(File.separator)+1,filepath_tiff.length());
//System.out.println("22222222222222222"+filepath);
//System.out.println("444444"+filepath_tiff);
//System.out.println("444444"+filename_jpg);
//System.out.println("444444"+filename_tif);
boolean isUp = FtpManager.put("FaxDec"+File.separator+filename_jpg, filepath);
if(isUp){//如果上传成功
//执行调用 jpg转tif文件
HttpRequester request = new HttpRequester();
request.setDefaultContentEncoding("utf-8");
//HttpRespons hr = request.sendGet("http://localhost:8080/Fax/FaxServlet?fileName="+fileNames);//上传成功后调用转tiff命令
//System.out.println(Java91Config.jpg2tifservlet+"?fileName="+filename_jpg);
HttpRespons hr = request.sendGet(Java91Config.jpg2tifservlet+"?fileName="+filename_jpg);//上传成功后调用转tiff命令
// System.out.println(hr.getContent());
if(null !=hr.getContent() && hr.getContent().length()>0){
//System.out.println("33333333333333"+File.separator+filename_tif);
filepath_tif = FtpManager.downFile("FaxDec"+File.separator+filename_tif);
}
}
}catch (Exception e){
e.printStackTrace();
throw new Java91Exception("创建TIF文件错误!请与管理员联系,确认图片服务器正常");
}
}
return filepath_tif;
}
//创建订单传真图片-供应商
public static String createOrderFaxPictureByCustomer(String bascDec, String barcode, String resultSrc, User user, Order order, List orderroomtypebeanList, List orderotherfeesList,
String orderType) {
if (null == user || null == order || null == orderroomtypebeanList || orderroomtypebeanList.size()<=0 || null == orderType || orderType.length()<=0)
return null;
String isprotocol="8";
try {
String pers = order.getCheckinpersons();
//String pers = "保钓委执委曾健成说,他们首选是从香港出发前往钓鱼岛宣示主权,但由于担心受到阻挠,因此,他们同时也拟定从台湾出发的方案。但最后从哪里出发,无明确说明。";
int perno = pers.length()/45+1;
BufferedImage imageHead = new BufferedImage(imageWidth, 250+(perno-1)*15+10, BufferedImage.TYPE_INT_RGB);
String barCodeDic= ImageFaxUtil.createBarcodeImage(bascDec, barcode);//条形码图片
File logofile = new File(Framework.servletRealPath+"faxFile"+File.separator+ "logo.jpg");
Image logoImage = javax.imageio.ImageIO.read(logofile); // 读取jpg等图片文件
InputStream barCodeStream = new FileInputStream(bascDec + barCodeDic);
BufferedImage barCodeImage = ImageIO.read(barCodeStream);
Graphics graphics = imageHead.getGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, imageWidth, 250+(perno-1)*15+10);
graphics.setColor(Color.BLACK);
graphics.drawImage(logoImage, 75, 30, null);
graphics.drawImage(barCodeImage, 560, 30, null);
graphics.setFont(fontPage);// 设置当前图片全局字体
graphics.drawLine(20, 129, 800, 129);//画线
//黑体 隶书 华文楷体
graphics.setFont(new Font("宋体",Font.BOLD, 15));//普通字体
//graphics.drawString(CommonUtil.getDefault(order.getHotelname())+" 订房部", 75, 185);// 酒店的名字
graphics.drawString(CommonUtil.getDefault(order.getCustomername())+" "+order.getMembername(), 75, 185);// 酒店的名字
//graphics.setFont(fontPage);// 设置当前图片全局字体
graphics.drawLine(45, 190, 295, 190);//画线
graphics.drawString(order.getHotelname(), 110, 205);
graphics.drawLine(45, 210, 280, 210);//画线
String pricingtype="";
if(order.getPricingtype().intValue() == 11 ){
pricingtype="客人前台现付";
}else{
if(order.getOrherhang().intValue()==1){
pricingtype="房费挂帐,杂费可挂帐";
}else{
pricingtype="房费挂帐,杂费客人自理";
}
}
graphics.drawString(pricingtype, 110, 230);
graphics.setFont(new Font("宋体",Font.PLAIN, 13));//普通字体
graphics.drawString("深圳市捷旅国际旅行社有限公司 www.jl-tour.com", 100, 110);
graphics.drawString("发送人/工号:", 50, 126);
graphics.drawString(user.getRealname()+"/"+user.getUsercd(), 135, 126);
graphics.drawString("电话:", 200, 126);
graphics.drawString(jltourPhoto, 236, 126);
graphics.drawString("传真:", 370, 126);
graphics.drawString(jltourFax, 402, 126);
graphics.drawString("发送时间:", 530, 126);
graphics.drawString(CommonUtil.getDateString(new java.util.Date(), "yyyy-MM-dd HH:mm"), 590, 126);
graphics.drawString("致:", 45, 185);
graphics.drawString("酒店名称:", 45, 205);// 酒店的名字
graphics.drawString("结算方式:", 45, 230);
graphics.drawString("客人姓名:", 45, 250);
graphics.setFont(new Font("宋体", Font.BOLD, 14));
graphics.drawLine(45, 235, 295, 235);//画线
int noys=250;
int test=0;
int i=0;
if(perno>1){
while(i<perno){
test = (((i)*45+45)>=pers.length())?pers.length():((i)*45+45-1);
graphics.drawString(pers.substring((i)*45,test), 105, noys);
noys = noys+15;
i++;
}
}else{
graphics.drawString(pers, 105, 250);
}
graphics.drawString("订单编号:", 600, 152);
graphics.drawString(order.getOrdercd(), 665, 152);
Font fontTitle = new Font("黑体", Font.BOLD, 20);
graphics.setFont(fontTitle);
graphics.drawString(orderType, 235, 155);
//BufferedImage bg_src = ImageFaxUtil.createBaseHeadBufImage(bascDec, ImageFaxUtil.createBarcodeImage(bascDec, barcode), user.getUsercd()+"/"+user.getRealname(), orderType, order);
BufferedImage bi_pricesrc = ImageFaxUtil.createImagePrice(orderroomtypebeanList, orderotherfeesList, orderType, order,"8","cus");
//File logofile = new File(Framework.servletRealPath+"faxFile\\"+ baseBottomFile);
//Image logo_src = javax.imageio.ImageIO.read(logofile); // 读取最下面的文件
//BufferedImage bottom =ImageFaxUtil.createImageBottom();
int bg_width = imageHead.getWidth(null);
int bg_height = imageHead.getHeight(null);
//int logo_width = bottom.getWidth(null);
//int logo_height = bottom.getHeight(null);
int bi_width = bi_pricesrc.getWidth(null);
int bi_height = bi_pricesrc.getHeight(null);
BufferedImage imgage = new BufferedImage(imageWidth, bg_height + bi_height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = imgage.createGraphics();
g2d.drawImage(imageHead, 0, 0, bg_width, bg_height, null);
// 组合价格
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 1.0f)); // 透明度设置开始
g2d.drawImage(bi_pricesrc, 0, bg_height, bi_width, bi_height, null);
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); // 透明度设置
// 结束
// 组合下面
//g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 1.0f)); // 透明度设置开始
//g2d.drawImage(bottom, 0, bg_height + bi_height, logo_width, logo_height, null);
//g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); // 透明度设置
// 结束
//图片黑白
//ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
//ColorConvertOp op = new ColorConvertOp(cs, null);
// imgage = op.filter(imgage, null);
FileOutputStream out = new FileOutputStream(Framework.servletRealPath+Java91Config.getFaxImageTempPath()+File.separator + resultSrc);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(imgage);
out.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
}
return resultSrc;
}
//供应商 订单传真 价格
public static BufferedImage createImagePriceByCustomer(List orderroomtypebeanList, List orderotherfeesList, String orderType, Order order) {
int imageHeight = 15 + orderroomtypebeanList.size() * linHieght + orderotherfeesList.size() * linHieght + linHieght + 10;
BufferedImage image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
Graphics graphicsPrice = image.getGraphics();
Font fontHead = new Font("宋体", Font.BOLD, 14);// 头部字
graphicsPrice.setFont(fontHead);
graphicsPrice.setColor(Color.WHITE);
graphicsPrice.fillRect(0, 0, imageWidth, imageHeight);
graphicsPrice.setColor(Color.BLACK);
graphicsPrice.drawString("类型", 15, 15);
graphicsPrice.drawString("房型", 65, 15);
graphicsPrice.drawString("入住/退房日期", 180, 15);
graphicsPrice.drawString("含早情况", 330, 15);
graphicsPrice.drawString("最晚到店", 450, 15);
if (order.getPricingtype() == 11) {// 现付
graphicsPrice.drawString("现付价", 555, 15);
} else {
graphicsPrice.drawString("结算价", 555, 15);
}
graphicsPrice.drawString("小计", 745, 15);
Font fontContent = new Font("楷体", Font.PLAIN, 14);// 头部字
graphicsPrice.setFont(fontContent);
int noY = 15;// 当前开始写的y坐标
double countPirce = 0;
if (null != orderroomtypebeanList) {
Orderroomtypebean orderroomtypebean,orderroomtypebeantemp;
for (int i = 0; i < orderroomtypebeanList.size(); i++) {
orderroomtypebean = (Orderroomtypebean) orderroomtypebeanList.get(i);
if(0!=orderroomtypebean.getOrderroomtypebeanidedit()){
continue;
}
String beantitle="";
Integer optiontype=orderroomtypebean.getOpttype().intValue();
if(0==optiontype){
if(orderroomtypebean.getHotelconfirmstatus().intValue()==1){
beantitle="已确认";
}else{
if(0!=orderroomtypebean.getOrderroomtypebeanidorg().intValue()){
for (int f = 0; f < orderroomtypebeanList.size();f++) {
orderroomtypebeantemp = (Orderroomtypebean) orderroomtypebeanList.get(f);
if(orderroomtypebeantemp.getOrderroomtypebeanid().intValue()==orderroomtypebean.getOrderroomtypebeanidorg().intValue()){
int optiontype2=orderroomtypebeantemp.getOpttype().intValue();
if(optiontype2==10){
beantitle="改价格";
}else if(optiontype2==11){
beantitle="减少间夜";
}else if(optiontype2==12){
beantitle="改房型";
}else if(optiontype2==13){
beantitle="撤消";
}
break;
}
}
}else{
beantitle="新订";
}
}
}else if(optiontype==10){
beantitle="价格修改";
}else if(optiontype==11){
beantitle="减少间夜数";
}else if(optiontype==12){
beantitle="修改房型";
}else if(optiontype==13){
beantitle="撤消房型";
}
noY = noY + linHieght;
graphicsPrice.drawString(beantitle, 15, noY);
graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getRoomtypenameratetype()), 65, noY);
graphicsPrice.drawString(CommonUtil.getDateString(orderroomtypebean.getCheckindate(), "M月d日")+"~"+CommonUtil.getDateString(orderroomtypebean.getCheckoutdate(), "M月d日")+" "+orderroomtypebean.getRoomqty()+"间 "+orderroomtypebean.getDays()+"晚", 150, noY);
Map map=new HashMap();
OrderroomtypepriceDao orderroomtypepriceDao=(OrderroomtypepriceDao) Framework.getDaoFactory().getBean("orderroomtypepriceDao");
int breakfast=10;
if(orderroomtypebean.getServicerate().intValue()==1){//该BEAN的所有PRICE 都为是一样的。
breakfast=orderroomtypebean.getIncludebreakfastqty2();
}else{
map.put("orderroomtypebeanid", orderroomtypebean.getOrderroomtypebeanid());
map.put("sortString", "includebreakfastqty2,night");
List pricelist=orderroomtypepriceDao.queryOrderroomtypeprices(map);
Orderroomtypeprice price=null;
for(int n=0;n<pricelist.size();n++){
price=(Orderroomtypeprice)pricelist.get(n);
}
}
graphicsPrice.drawString(OptionManager.getNameByCode(OptionType.inbreakfast, "" + orderroomtypebean.getIncludebreakfastqty2()), 330, noY);
graphicsPrice.drawString(orderroomtypebean.getLatestarrivaltime(), 450, noY);
/*
* if(order.getPricingtype()==11){//现付
* if(orderroomtypebean.getIsequalsaleprice()==1){
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getAvasaleprice()),
* 675, noY); }else{
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getPricenotesaleprice()),
* 675, noY); }
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getAvasaleprice()*orderroomtypebean.getDays()*orderroomtypebean.getRoomqty()),
* 745, noY); }else{
* if(orderroomtypebean.getIsequalbaseprice()==1){
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getAvabaseprice()),
* 675, noY); }else{
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getPricenotebaseprice()),
* 675, noY); }
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getAvabaseprice()*orderroomtypebean.getDays()*orderroomtypebean.getRoomqty()),
* 745, noY); }
*/
if (order.getPricingtype().intValue() == 11) {// 现付
graphicsPrice.drawString("RMB "+(int) orderroomtypebean.getAvasaleprice().intValue(), 555, noY);//现付价
graphicsPrice.drawString(CommonUtil.getDefault((int) orderroomtypebean.getAvasaleprice().intValue() * orderroomtypebean.getDays()* orderroomtypebean.getRoomqty()), 745, noY);//现付合计
countPirce = countPirce + (int) orderroomtypebean.getAvasaleprice().intValue() * orderroomtypebean.getDays() * orderroomtypebean.getRoomqty();
} else {
graphicsPrice.drawString("RMB "+(int) orderroomtypebean.getAvapreeprice().intValue(), 555, noY);//底价
graphicsPrice.drawString(CommonUtil.getDefault((int) orderroomtypebean.getAvapreeprice().intValue() * orderroomtypebean.getDays()* orderroomtypebean.getRoomqty()), 745, noY);
countPirce = countPirce + (int) orderroomtypebean.getAvapreeprice().intValue() * orderroomtypebean.getDays() * orderroomtypebean.getRoomqty();
}
}
}
double sumprice = 0;
graphicsPrice.setFont(fontContent);
if (null != orderotherfeesList) {
Orderotherfees orderotherfees;
for (int i = 0; i < orderotherfeesList.size(); i++) {
orderotherfees = (Orderotherfees) orderotherfeesList.get(i);
sumprice = sumprice + orderotherfees.getTotalamount();
String otherfeeString="";
String begindates="";
String enddates="";
String dates="";
begindates=CommonUtil.getDateString(orderotherfees.getBegindate(), "M月d日");
if(null==orderotherfees.getEnddate()){
dates=begindates;
}else{
enddates=CommonUtil.getDateString(orderotherfees.getEnddate(), "M月d日");
dates=begindates+"~"+enddates;
}
otherfeeString=otherfeeString+dates;
if (orderotherfees.getFeetype().intValue() == 2) {//早餐
otherfeeString=otherfeeString+" 加"+OptionManager.getNameByCode(OptionType.breaktype, "" + orderotherfees.getBreakfasttype())+" ";
} else {//加床
otherfeeString=otherfeeString+" 加床 ";
}
//otherfeeString=otherfeeString+order.getCurrency()+" "+orderotherfees.getBaseprice()+" * "+orderotherfees.getAmount()+" 份 ";
if(null!=orderType && orderType.length()>2){
orderType=orderType.substring(0,orderType.length()-1);
}
noY = noY + linHieght;
graphicsPrice.drawString(orderType, 15, noY);
graphicsPrice.drawString(otherfeeString, 150, noY);
graphicsPrice.drawString("RMB "+orderotherfees.getUnitprice()+" * "+orderotherfees.getAmount()+" 份 ", 555, noY);
graphicsPrice.drawString(CommonUtil.getDefault(orderotherfees.getTotalamount()), 745, noY);
}
}
graphicsPrice.drawString("总计(RMB):", 655, noY + linHieght);
graphicsPrice.drawString(countPirce + sumprice + "", 745, noY + linHieght);
return image;
}
public static String createDailyauditFaxPicture(String bascDec, String barcode, User user, String resultSrc, List orderitemList, Map orderitemsizeMap,
Map orderitemidDateStatusMap, Dailyauditstatus dailyauditstatus) {
if (null == user || null == bascDec || null == barcode || null == resultSrc || null == orderitemList || null == orderitemsizeMap || null == orderitemidDateStatusMap
|| null == dailyauditstatus)
return null;
try {
BufferedImage bg_src = ImageFaxUtil.createBaseHeadDayBufImageNew(bascDec, ImageFaxUtil.createBarcodeImage(bascDec, barcode), user, "日审单", dailyauditstatus);
BufferedImage bi_pricesrc = ImageFaxUtil.createImageDayPriceNew(orderitemList, orderitemsizeMap, orderitemidDateStatusMap, dailyauditstatus);
//BufferedImage bg_src = ImageFaxUtil.createBaseHeadDayBufImage(bascDec, ImageFaxUtil.createBarcodeImage(bascDec, barcode), userName, "日审单", dailyauditstatus);
//BufferedImage bi_pricesrc = ImageFaxUtil.createImageDayPrice(orderitemList, orderitemsizeMap, orderitemidDateStatusMap, dailyauditstatus);
BufferedImage bottomImage = ImageFaxUtil.createDailyauditImageBottom();
int bg_width = bg_src.getWidth(null);
int bg_height = bg_src.getHeight(null);
int bi_width = bi_pricesrc.getWidth(null);
int bi_height = bi_pricesrc.getHeight(null);
int bottom_height = bottomImage.getHeight(null);
BufferedImage imgage = new BufferedImage(bg_width, bg_height + bi_height+bottom_height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = imgage.createGraphics();
g2d.drawImage(bg_src, 0, 0, bg_width, bg_height, null);
// 组合价格
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 1.0f)); // 透明度设置开始
g2d.drawImage(bi_pricesrc, 0, bg_height, bi_width, bi_height, null);
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); // 透明度设置
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 1.0f)); // 透明度设置开始
g2d.drawImage(bottomImage, 0, bi_height+bg_height, bi_width,bottom_height, null);
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); // 透明度设置
//图片黑白
//ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
//ColorConvertOp op = new ColorConvertOp(cs, null);
//imgage = op.filter(imgage, null);
FileOutputStream out = new FileOutputStream(Framework.servletRealPath+Java91Config.getFaxImageTempPath()+File.separator + resultSrc);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(imgage);
out.close();
} catch (IOException e) {
e.printStackTrace();
return null;
}
return resultSrc;
}
// 供应商 订单底图
public static BufferedImage createDailyauditImageBottom() {
BufferedImage image = new BufferedImage(imageWidth,220, BufferedImage.TYPE_INT_RGB);
Graphics graphics = image.getGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, imageWidth, 220);
graphics.setColor(Color.BLACK);
graphics.setFont(fontPage);// 设置当前图片全局字体
graphics.drawString("TO:各大酒店销售部", 15, 10);
graphics.drawString("FR:深圳捷旅假期", 15, 30);
graphics.drawString("×××以上是我社入住贵酒店房态查询表,请填写入住房间号码,若已退房客房请备注退房时间。未到店请写未到,登记入住客人并非", 30, 50);
graphics.drawString("预定名字,请注明登记客人名字;续住一些特殊情况,请在房态表上注明,如果客人是入住当天退房,请备注有无返佣并请尽快回传,", 30, 70);
graphics.drawString("谢谢。", 30, 90);
graphics.drawLine(30, 125, 150, 125);//画线
graphics.drawString("请签名确认", 160, 125);
graphics.drawString("请回传 33389800 或 33396877", 30, 145);
graphics.drawString("电话:0755-33394811 ", 30, 165);
graphics.drawString("*******非常感谢*******", 30, 185);
graphics.drawString("晚上请打3339777 按 1 麻烦请尽快回传,谢谢", 30, 205);
return image;
}
public static BufferedImage createBaseHeadDayBufImageNew(String bascDec, String barCodeDic,User user, String title, Dailyauditstatus dailyauditstatus) throws IOException {
BufferedImage imageHead = new BufferedImage(imageWidth, 210, BufferedImage.TYPE_INT_RGB);
File logofile = new File(Framework.servletRealPath+"faxFile"+File.separator+ "logo.jpg");
Image logoImage = javax.imageio.ImageIO.read(logofile); // 读取jpg等图片文件
InputStream barCodeStream = new FileInputStream(bascDec + barCodeDic);
BufferedImage barCodeImage = ImageIO.read(barCodeStream);
Graphics graphics = imageHead.getGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, imageWidth, 210);
graphics.setColor(Color.BLACK);
graphics.drawImage(logoImage, 75, 30, null);
graphics.drawImage(barCodeImage, 560, 30, null);
graphics.setFont(fontPage);// 设置当前图片全局字体
graphics.drawLine(20, 129, 800, 129);//画线
//黑体 隶书 华文楷体
graphics.setFont(new Font("宋体",Font.BOLD, 15));//普通字体
graphics.drawString(CommonUtil.getDefault(dailyauditstatus.getSuppliername()), 75, 185);//供应商名字
graphics.drawString("订单信息栏:", 45, 205);
graphics.setFont(new Font("宋体",Font.PLAIN, 13));//普通字体
graphics.drawString("深圳市捷旅国际旅行社有限公司 www.jl-tour.com", 100, 110);
graphics.drawString("发送人/工号:", 50, 126);
graphics.drawString(user.getRealname()+"/"+user.getUsercd(), 135, 126);
graphics.drawString("电话:", 200, 126);
graphics.drawString(jltourPhoto, 236, 126);
graphics.drawString("传真:", 370, 126);
graphics.drawString(jltourFax, 402, 126);
graphics.drawString("发送时间:", 530, 126);
graphics.drawString(CommonUtil.getDateString(new java.util.Date(), "yyyy-MM-dd HH:mm"), 590, 126);
graphics.drawString("致:", 45, 185);
graphics.drawString("请确认 "+CommonUtil.getDateString(dailyauditstatus.getNight(),"M月d日")+" 的入住情况", 145, 205);
graphics.setFont(new Font("宋体", Font.BOLD, 14));
Font fontTitle = new Font("黑体", Font.BOLD, 20);
graphics.setFont(fontTitle);
graphics.drawString(title, 235, 155);
return imageHead;
}
public static BufferedImage createBaseHeadDayBufImage(String bascDec, String barCodeDic, String userName, String title, Dailyauditstatus dailyauditstatus) throws IOException {
BufferedImage imageHead = new BufferedImage(imageWidth, 145, BufferedImage.TYPE_INT_RGB);
File logofile = new File(Framework.servletRealPath+"faxFile"+File.separator+ "logo.jpg");
Image logoImage = javax.imageio.ImageIO.read(logofile); // 读取jpg等图片文件
InputStream barCodeStream = new FileInputStream(bascDec + barCodeDic);
BufferedImage barCodeImage = ImageIO.read(barCodeStream);
Graphics graphics = imageHead.getGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, imageWidth, 210);
graphics.setColor(Color.BLACK);
graphics.drawImage(logoImage, 0, 0, null);
graphics.drawImage(barCodeImage, 320, 0, null);
graphics.setFont(fontPage);// 设置当前图片全局字体
graphics.drawString("携旅电话:", 615, 10);// photo
graphics.drawString(jltourPhoto, 680, 10);// photo
graphics.drawString("携旅传真:", 615, 30);// photo
graphics.drawString(jltourFax, 680, 30);// fax
graphics.drawString("发送人:", 628, 50);// photo
graphics.drawString(CommonUtil.getDefault(userName), 680, 50);// 发送人
graphics.drawString("发送时间:", 615, 100);// 携旅订单号
graphics.drawString(CommonUtil.getDateString(new java.util.Date(), "yyyy-MM-dd HH:mm"), 680, 100);// 携旅订单号
graphics.setFont(new Font("宋体", Font.BOLD, 15));
graphics.drawString("致:", 15, 110);// 酒店的名字
graphics.drawString(CommonUtil.getDefault(dailyauditstatus.getSuppliername())+" ", 40, 110);// 酒店的名字
graphics.setFont(new Font("宋体", Font.BOLD, 13));
graphics.drawString("订单信息栏 请确认"+CommonUtil.getDateString(dailyauditstatus.getNight(), "M月d日")+"的入住情况", 15, 130);// 备注信息
graphics.drawLine(15, 138, 800, 138);//画线
Font fontTitle = new Font("宋体", Font.BOLD, 24);
graphics.setFont(fontTitle);
graphics.drawString("日审单", 345, 90);
return imageHead;
// InputStream imagein = new FileInputStream(Framework.servletRealPath+"faxFile\\"+ baseHeadDayFile);
// InputStream imagein2 = new FileInputStream(bascDec +barCodeDic);
// BufferedImage image = ImageIO.read(imagein);
// BufferedImage image2 = ImageIO.read(imagein2);
// Graphics graphics = image.getGraphics();
// graphics.drawImage(image2, 320, 10, null);
// graphics.setColor(Color.BLACK);
// graphics.setFont(fontPage);// 设置当前图片全局字体
// graphics.drawString(jltourPhoto, 680, 20);// photo
// graphics.drawString(jltourFax, 680, 40);// fax
// graphics.drawString(CommonUtil.getDefault(userName), 680, 60);// 发送人
// // graphics.drawString(CommonUtil.getDefault(order.getOrdercd()), 680,
// // 80);//携旅订单号
// graphics.drawString(CommonUtil.getDateString(new java.util.Date(), "yyyy-MM-dd HH:mm"), 680, 130);// 发送时间
// graphics.drawString(CommonUtil.getDefault(dailyauditstatus.getSuppliername()), 50, 130);// 酒店的名字
// // graphics.drawString(CommonUtil.getDefault(dailyauditstatus.get), 78,
// // 211);//结算方式
// Font fontTitle = new Font("宋体", Font.BOLD, 24);
// graphics.setFont(fontTitle);
// graphics.drawString(title, 360, 100);
// imagein.close();
// imagein2.close();
// return image;
}
public static BufferedImage createImageDayPrice(List orderitemList, Map orderitemsizeMap, Map orderitemidDateStatusMap, Dailyauditstatus dailyauditstatus) {
int imageHeight = 25+25+orderitemList.size()*25;
//int imageHeight = 800;
OrderDao orderDao=(OrderDao)Framework.getDaoFactory().getBean("orderDao");
Order order=null;
BufferedImage image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
Graphics graphicsPrice = image.getGraphics();
Font fontHead = new Font("宋体", Font.BOLD, 14);// 头部字
graphicsPrice.setFont(fontHead);
graphicsPrice.setColor(Color.WHITE);
graphicsPrice.fillRect(0, 0, imageWidth, imageHeight);
graphicsPrice.setColor(Color.BLACK);
graphicsPrice.drawString("订单编号", 20, 20);
graphicsPrice.drawString("房型", 130, 20);
graphicsPrice.drawString("入住/退房日期", 200, 20);
graphicsPrice.drawString("房号", 310, 20);
graphicsPrice.drawString("入住人", 350, 20);
graphicsPrice.setFont(new Font("楷体", Font.PLAIN, 13));
int beginwite = 380;
if (null != dailyauditstatus) {
Date startdate = (Date) DateUtil.getDate(dailyauditstatus.getNight(), -2);
Date currentDate = startdate;
int days = 6;
for (int g = 0; g < 3; g++) {
if(currentDate.getTime()==dailyauditstatus.getNight().getTime()){
graphicsPrice.setColor(Color.gray);
}else{
graphicsPrice.setColor(Color.BLACK);
}
beginwite = beginwite + 38;
graphicsPrice.drawString(CommonUtil.getDateString(currentDate, "M.d"), beginwite, 10);
graphicsPrice.drawString("周" + CommonUtil.getChineseDayOfWeek(currentDate), beginwite, 25);
currentDate = (Date) DateUtil.getDate(currentDate, 1);
}
for (int g = 3; g < days; g++) {
if(currentDate.getTime()==dailyauditstatus.getNight().getTime()){
graphicsPrice.setColor(Color.gray);
}else{
graphicsPrice.setColor(Color.BLACK);
}
beginwite = beginwite + 38;
graphicsPrice.drawString(CommonUtil.getDateString(currentDate, "M.d"), beginwite, 10);
graphicsPrice.drawString("周" + CommonUtil.getChineseDayOfWeek(currentDate), beginwite, 25);
currentDate = (Date) DateUtil.getDate(currentDate, 1);
}
}
graphicsPrice.setFont(fontHead);
graphicsPrice.drawString("已离店",640, 20);
graphicsPrice.drawString("备注/确认号", 700, 20);
Font fontContent = new Font("宋体", Font.PLAIN, 14);// 内容字
graphicsPrice.setFont(fontContent);
int noY = 25;// 当前开始写的y坐标
Date startdate = (Date) DateUtil.getDate(dailyauditstatus.getNight(), -2);
Date currentDate = startdate;
int days = 6;
Orderitem orderitem=null,orderitemLast=null,orderitemNext=null;
beginwite = 380;
int beginId = 0;
int start=0;
int end=1;
boolean flat = false;
for (int i = 0; i < orderitemList.size(); i++) {
noY = noY + linHieght;
orderitem = (Orderitem) orderitemList.get(i);
Integer orderitemsize = 0;
orderitemsize = (Integer) orderitemsizeMap.get(orderitem.getOrderid());
if(i>0){
orderitemLast=(Orderitem)orderitemList.get(i-1);
}
if(i<orderitemList.size()-1){
orderitemNext=(Orderitem)orderitemList.get(i+1);
}
if(null==orderitemLast ){
start=1;
//System.out.println("pricebeanitemLast==NULL start:"+start);
}else if((int)orderitemLast.getOrderid()==(int)orderitem.getOrderid()){
start=8;
//System.out.println("pricebeanitemLast.getPricebeanid()==pricebeanitem.getPricebeanid() start:"+start);
}else if((int)orderitemLast.getOrderid()!=(int)orderitem.getOrderid()){
start=1;
//System.out.println("pricebeanitemLast.getPricebeanid():"+pricebeanitemLast.getPricebeanid()+",,"+pricebeanitem.getPricebeanid());
//System.out.println("pricebeanitemLast.getPricebeanid()!=pricebeanitem.getPricebeanid() start:"+start);
}
String roomtypenameratetype=orderitem.getRoomtypenameratetype()+" "+orderitem.getRoomqty()+"间";
if(null!=orderitemLast && orderitem.getRoomtypenameratetype().equals(orderitemLast.getRoomtypenameratetype())&& start!=1){
roomtypenameratetype="";
}
if (beginId != orderitem.getOrderid()) {
flat = true;
} else {
flat = false;
}
beginId = orderitem.getOrderid();
String pricingtype="";
if(orderitem.getPricingtype().intValue()==11){
pricingtype="现付";
}else{
pricingtype="挂帐";
}
if (null != orderitemsize) {
if (flat) {
graphicsPrice.setColor(Color.gray);
graphicsPrice.drawLine(15,noY-20 , 800, noY-20);//画线
graphicsPrice.setColor(Color.BLACK);
if (orderitemsize == 1) {
graphicsPrice.drawString(CommonUtil.getDefault(orderitem.getOrdercd()), 20, noY);
graphicsPrice.drawString(pricingtype, 40, noY+13);
} else {
graphicsPrice.drawString(CommonUtil.getDefault(orderitem.getOrdercd()), 20, noY + ((orderitemsize * 10) / 2));
graphicsPrice.drawString(pricingtype, 40, noY + ((orderitemsize * 10) / 2)+20);
}
}
}
graphicsPrice.drawString(roomtypenameratetype, 115, noY);
graphicsPrice.drawString(CommonUtil.getDateString(orderitem.getCheckinday(), "M.d")+"-"+CommonUtil.getDateString(orderitem.getCheckoutday(), "M.d")+" "+orderitem.getDays()+"晚", 200, noY);
graphicsPrice.drawString(CommonUtil.getDefault(orderitem.getRoomno()), 310, noY);
graphicsPrice.drawString(CommonUtil.getDefault(orderitem.getCheckinperson()), 350, noY);
currentDate = startdate;
Date checkoutday = DateUtil.getDate(orderitem.getCheckoutday(), -1);
for (int h = 0; h < days; h++) {
beginwite = beginwite + 38;
if (DateUtil.between(currentDate, orderitem.getCheckinday(), checkoutday)) {
Integer checkinstatus = (Integer) orderitemidDateStatusMap.get(CommonUtil.getDateString(currentDate, "yyyy-MM-dd") + orderitem.getOrderitemid());
if (null == checkinstatus || checkinstatus == 0) {
if(DateUtil.compare(currentDate,dailyauditstatus.getNight())==0){
graphicsPrice.drawString(CommonUtil.getDefault("□"), beginwite + 3, noY);
}else{
graphicsPrice.drawString(CommonUtil.getDefault("-"), beginwite + 3, noY);
}
} else if (checkinstatus == 1) {
graphicsPrice.drawString(CommonUtil.getDefault("√"), beginwite + 3, noY);
} else if (checkinstatus == 8) {
graphicsPrice.drawString(CommonUtil.getDefault("×"), beginwite + 3, noY);
}
}
currentDate = (Date) DateUtil.getDate(currentDate, 1);
}
graphicsPrice.drawString("□",beginwite + 40, noY);
beginwite = 380;
if (flat) {
order=orderDao.retrieveOrder(orderitem.getOrderid());
graphicsPrice.drawString(CommonUtil.getDefault(order.getConfirmno()), 700, noY);
}
}
graphicsPrice.drawLine(15, 35+( orderitemList.size() * 25), 800, 35+( orderitemList.size() * 25));//画线
return image;
}
public static BufferedImage createImageDayPriceNew(List orderitemList, Map orderitemsizeMap, Map orderitemidDateStatusMap, Dailyauditstatus dailyauditstatus) {
int imageHeight = 25+25+orderitemList.size()*25;
OrderDao orderDao=(OrderDao)Framework.getDaoFactory().getBean("orderDao");
Order order=null;
BufferedImage image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
Graphics graphicsPrice = image.getGraphics();
Font fontHead = new Font("宋体", Font.BOLD, 14);// 头部字
graphicsPrice.setFont(fontHead);
graphicsPrice.setColor(Color.WHITE);
graphicsPrice.fillRect(0, 0, imageWidth, imageHeight);
graphicsPrice.setColor(Color.BLACK);
graphicsPrice.drawString("酒店名称", 45, 15);
graphicsPrice.drawString("客人姓名", 150, 15);
graphicsPrice.drawString("入住/退房", 242, 15);
graphicsPrice.drawString("退房日期", 310, 15);
graphicsPrice.drawString("核对日期", 380, 15);
graphicsPrice.drawString("间数", 460, 15);
graphicsPrice.drawString("是否续住", 520, 15);
graphicsPrice.drawString("房号", 480, 15);
graphicsPrice.drawString("确认号", 710, 15);
graphicsPrice.drawLine(50, 15+5, 200, 15+5);//最后横线 换行150
graphicsPrice.setFont(new Font("楷体", Font.PLAIN, 13));
graphicsPrice.setFont(fontHead);
Font fontContent = new Font("宋体", Font.PLAIN, 14);// 内容字
graphicsPrice.setFont(fontContent);
int noY = 25;// 当前开始写的y坐标
graphicsPrice.drawLine(310, 15+5, 370, 15+5);//最后横线 换行150
//50 4个字
//画坚线
//分行120
graphicsPrice.drawLine(42, 0, 42, noY);//第一条竖线
//画横线
graphicsPrice.drawLine(42, 0, 760, 0);//第一条横线
graphicsPrice.drawLine(42, noY, 760, noY);//最后一条横线
return image;
}
public static List getTiffStreamByFileName(String fileName){
List result = new ArrayList();
if(null != fileName && fileName.length()>0){
String tiffName = fileName.substring(0,fileName.indexOf("."))+".tif";
try{
/*
OutputStream os = new FileOutputStream(tiffName);
TIFFEncodeParam param =new TIFFEncodeParam();
ImageEncoder enc = ImageCodec.createImageEncoder("TIFF", os,param);
enc.encode(src);
os.close();
*/
String fileNames= fileName.substring(fileName.lastIndexOf(File.separator)+1,fileName.length());
String tiffNames = tiffName.substring(tiffName
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.color.ColorSpace;
import java.awt.geom.AffineTransform;
import java.awt.geom.Line2D;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.awt.image.ColorConvertOp;
import java.awt.image.DataBufferByte;
import java.awt.image.RenderedImage;
import java.awt.image.WritableRaster;
import java.awt.image.renderable.ParameterBlock;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import javax.imageio.ImageIO;
import javax.media.jai.Histogram;
import javax.media.jai.JAI;
import javax.media.jai.PlanarImage;
import javax.media.jai.RenderedOp;
import org.apache.struts2.ServletActionContext;
import org.krysalis.barcode4j.impl.code39.Code39Bean;
import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider;
import org.krysalis.barcode4j.tools.UnitConv;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
import com.jltour.authority.auto.beans.User;
import com.jltour.common.constant.OptionType;
import com.jltour.common.exception.Java91Exception;
import com.jltour.common.framework.Framework;
import com.jltour.common.framework.Java91Config;
import com.jltour.common.manager.FtpManager;
import com.jltour.common.manager.OptionManager;
import com.jltour.common.manager.fax.HttpRequester;
import com.jltour.common.manager.fax.HttpRespons;
import com.jltour.common.manager.interfaces.FaxManager;
import com.jltour.reserve.aManual.dao.ReserveDao;
import com.jltour.reserve.auto.beans.Dailyauditstatus;
import com.jltour.reserve.auto.beans.Order;
import com.jltour.reserve.auto.beans.Orderitem;
import com.jltour.reserve.auto.beans.Orderitemdate;
import com.jltour.reserve.auto.beans.Orderotherfees;
import com.jltour.reserve.auto.beans.Orderroomtypebean;
import com.jltour.reserve.auto.beans.Orderroomtypeprice;
import com.jltour.reserve.auto.dao.OrderDao;
import com.jltour.reserve.auto.dao.OrderroomtypepriceDao;
import com.sun.image.codec.jpeg.ImageFormatException;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
import com.sun.media.jai.codec.BMPEncodeParam;
import com.sun.media.jai.codec.FileSeekableStream;
import com.sun.media.jai.codec.ImageCodec;
import com.sun.media.jai.codec.ImageDecoder;
import com.sun.media.jai.codec.ImageEncoder;
import com.sun.media.jai.codec.JPEGEncodeParam;
import com.sun.media.jai.codec.SeekableStream;
import com.sun.media.jai.codec.TIFFDecodeParam;
import com.sun.media.jai.codec.TIFFEncodeParam;
import com.sun.media.jai.codecimpl.BMPCodec;
import com.sun.media.jai.codecimpl.BMPImageEncoder;
/**
* 传真图片工具类
*
* @author huangjin
*
*/
public class ImageFaxUtil {
// private static String bascDec ="D:\\reportXmlFile\\ok\\" ;
private static String baseHeadFile = "baseHead.bmp";//baseHeadMember.bmp
private static String baseHeadMemberFile = "baseHeadMember.bmp";
private static String baseHeadDayFile = "baseHeadDay.bmp";
private static String baseBottomFile = "baseBottom.bmp";
private static final int imageWidth = 800;// 传真文件宽度
private static final Font fontPage = new Font("宋体", Font.BOLD, 14);// 当前页面的字体设置
//private static final Font fontPage = new Font("黑体", Font.PLAIN, 12);// 当前页面的字体设置
private static String jltourPhoto = "86-755-33397777";
private static final String jltourFax = "86-755-33389800";
private static final int linHieght = 25;
//创建订单传真图片-供应商
public static String createOrderFaxPictureBySupplier(String bascDec, String barcode, String resultSrc, User user, Order order, List orderroomtypebeanList, List orderotherfeesList,
String orderType,String isprotocol) {
if (null == user || null == order || null == orderroomtypebeanList || orderroomtypebeanList.size()<=0 || null == orderType || orderType.length()<=0)
return null;
//System.out.println("33333333333333333333333333333333333333333333333333333333333333333333333333");
try {
if(null == isprotocol || isprotocol.length()<=0){
isprotocol="8";
}
String pers = order.getCheckinpersons();
//String pers = "保钓委执委曾健成说,他们首选是从香港出发前往钓鱼岛宣示主权,但由于担心受到阻挠,因此,他们同时也拟定从台湾出发的方案。但最后从哪里出发,无明确说明。";
int perno = pers.length()/45+1;
BufferedImage imageHead = new BufferedImage(imageWidth, 250+(perno-1)*15+10, BufferedImage.TYPE_INT_RGB);
String barCodeDic= ImageFaxUtil.createBarcodeImage(bascDec, barcode);//条形码图片
File logofile = new File(Framework.servletRealPath+"faxFile"+File.separator+ "logo.jpg");
Image logoImage = javax.imageio.ImageIO.read(logofile); // 读取jpg等图片文件
InputStream barCodeStream = new FileInputStream(bascDec + barCodeDic);
BufferedImage barCodeImage = ImageIO.read(barCodeStream);
Graphics graphics = imageHead.getGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, imageWidth, 250+(perno-1)*15+10);
graphics.setColor(Color.BLACK);
graphics.drawImage(logoImage, 75, 30, null);
graphics.drawImage(barCodeImage, 560, 30, null);
graphics.setFont(fontPage);// 设置当前图片全局字体
graphics.drawLine(20, 129, 800, 129);//画线
//黑体 隶书 华文楷体
graphics.setFont(new Font("宋体",Font.BOLD, 15));//普通字体
graphics.drawString(CommonUtil.getDefault(order.getHotelname())+" 订房部", 75, 185);// 酒店的名字
//graphics.setFont(fontPage);// 设置当前图片全局字体
graphics.drawLine(45, 190, 295, 190);//画线
graphics.drawString(order.getHotelname(), 110, 205);
graphics.drawLine(45, 210, 280, 210);//画线
String pricingtype="";
if(order.getPricingtype().intValue() == 11 ){
pricingtype="客人前台现付";
}else{
if(order.getOrherhang().intValue()==1){
pricingtype="房费挂帐,杂费可挂帐";
}else{
pricingtype="房费挂帐,杂费客人自理";
}
}
graphics.drawString(pricingtype, 110, 230);
graphics.setFont(new Font("宋体",Font.PLAIN, 13));//普通字体
graphics.drawString("深圳市捷旅国际旅行社有限公司 www.jl-tour.com", 100, 110);
graphics.drawString("发送人/工号:", 50, 126);
graphics.drawString(user.getRealname()+"/"+user.getUsercd(), 135, 126);
graphics.drawString("电话:", 200, 126);
graphics.drawString(jltourPhoto, 236, 126);
graphics.drawString("传真:", 370, 126);
graphics.drawString(jltourFax, 402, 126);
graphics.drawString("发送时间:", 530, 126);
graphics.drawString(CommonUtil.getDateString(new java.util.Date(), "yyyy-MM-dd HH:mm"), 590, 126);
graphics.drawString("致:", 45, 185);
graphics.drawString("酒店名称:", 45, 205);// 酒店的名字
graphics.drawString("结算方式:", 45, 230);
graphics.drawString("客人姓名:", 45, 250);
graphics.setFont(new Font("宋体", Font.BOLD, 14));
graphics.drawLine(45, 235, 295, 235);//画线
int noys=250;
int test=0;
int i=0;
if(perno>1){
while(i<perno){
test = (((i)*45+45)>=pers.length())?pers.length():((i)*45+45-1);
graphics.drawString(pers.substring((i)*45,test), 105, noys);
noys = noys+15;
i++;
}
}else{
graphics.drawString(pers, 105, 250);
}
graphics.drawString("订单编号:", 600, 152);
graphics.drawString(order.getOrdercd(), 665, 152);
Font fontTitle = new Font("黑体", Font.BOLD, 20);
graphics.setFont(fontTitle);
graphics.drawString(orderType, 235, 155);
//BufferedImage bg_src = ImageFaxUtil.createBaseHeadBufImage(bascDec, ImageFaxUtil.createBarcodeImage(bascDec, barcode), user.getUsercd()+"/"+user.getRealname(), orderType, order);
BufferedImage bi_pricesrc = ImageFaxUtil.createImagePrice(orderroomtypebeanList, orderotherfeesList, orderType, order,isprotocol,"sup");
//File logofile = new File(Framework.servletRealPath+"faxFile\\"+ baseBottomFile);
//Image logo_src = javax.imageio.ImageIO.read(logofile); // 读取最下面的文件
BufferedImage bottom =ImageFaxUtil.createImageBottom();
int bg_width = imageHead.getWidth(null);
int bg_height = imageHead.getHeight(null);
int logo_width = bottom.getWidth(null);
int logo_height = bottom.getHeight(null);
int bi_width = bi_pricesrc.getWidth(null);
int bi_height = bi_pricesrc.getHeight(null);
BufferedImage imgage = new BufferedImage(imageWidth, bg_height + logo_height + bi_height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = imgage.createGraphics();
g2d.drawImage(imageHead, 0, 0, bg_width, bg_height, null);
// 组合价格
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 1.0f)); // 透明度设置开始
g2d.drawImage(bi_pricesrc, 0, bg_height, bi_width, bi_height, null);
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); // 透明度设置
// 结束
// 组合下面
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 1.0f)); // 透明度设置开始
g2d.drawImage(bottom, 0, bg_height + bi_height, logo_width, logo_height, null);
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); // 透明度设置
// 结束
//图片黑白
//ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
//ColorConvertOp op = new ColorConvertOp(cs, null);
// imgage = op.filter(imgage, null);
FileOutputStream out = new FileOutputStream(Framework.servletRealPath+Java91Config.getFaxImageTempPath()+File.separator + resultSrc);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(imgage);
out.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
}
return resultSrc;
}
//生成条形码文件 返回对应的生成的条形码文件的图片全称
public static String createBarcodeImage(String bascDec, String content) throws IOException {
String result = "";
Code39Bean bean = new Code39Bean();
final int dpi = 150;
bean.setModuleWidth(UnitConv.in2mm(1.0f / dpi)); // makes the narrow
// bar
bean.setHeight(10);
bean.setWideFactor(3);
bean.doQuietZone(false);
File outputFile = new File(bascDec + content + "barcode.jpg");
OutputStream out = new FileOutputStream(outputFile);
try {
BitmapCanvasProvider canvas = new BitmapCanvasProvider(out, "image/jpeg", dpi, BufferedImage.TYPE_BYTE_BINARY, false, 0);
bean.generateBarcode(canvas, content);
canvas.finish();
result = content + "barcode.jpg";
} finally {
out.close();
}
return result;
}
//供应商 订单底图
public static BufferedImage createImageBottom() {
BufferedImage image = new BufferedImage(imageWidth, 180, BufferedImage.TYPE_INT_RGB);
Graphics graphics = image.getGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, imageWidth, 210);
graphics.setColor(Color.BLACK);
graphics.setFont(fontPage);// 设置当前图片全局字体
graphics.drawLine(55, 10, 760, 10);//画线
graphics.drawString("酒店确认栏", 55, 30);// photo
graphics.drawString("□ 本单确认", 85, 50);// photo
graphics.drawString("□ 本单不确认及原因", 205, 50);//
graphics.drawLine(345, 60, 760, 60);//画线
graphics.drawString("确认号:", 85, 80);// photo
graphics.drawLine(125, 90, 760, 90);//画线
graphics.drawString("签名栏:", 85, 120);// photo
graphics.drawLine(125, 130, 760, 130);//画线
graphics.drawString("酒店备注:", 85, 160);// photo
graphics.drawLine(125, 169, 760, 169);//画线
return image;
}
public static BufferedImage createImageBottomByCustomer() {
BufferedImage image = new BufferedImage(imageWidth, 160, BufferedImage.TYPE_INT_RGB);
Graphics graphics = image.getGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, imageWidth, 210);
graphics.setColor(Color.BLACK);
graphics.setFont(fontPage);// 设置当前图片全局字体
graphics.drawLine(15, 0, 800, 0);//画线
return image;
}
//供应商 订单传真 价格
public static BufferedImage createImagePrice(List orderroomtypebeanList, List orderotherfeesList, String orderType, Order order,String isprotocol,String cus_suptype) {
int noCount=0;
double countPirce=0;
if (null != orderroomtypebeanList) {
Orderroomtypebean orderroomtypebean;
int priceRoomLength=0;
String showpricenotes="";
for (int i = 0; i < orderroomtypebeanList.size(); i++) {
orderroomtypebean = (Orderroomtypebean) orderroomtypebeanList.get(i);
if("1".equals(isprotocol)){
orderroomtypebean.setPricenotebaseprice("协议价");
showpricenotes="协议价";
orderroomtypebean.setCreateby("协议价");
}else{
if(orderroomtypebean.getPricingtype()==11){
if("sup".equals(cus_suptype)){
if(null==orderroomtypebean.getIsequalsaleprice() || orderroomtypebean.getIsequalsaleprice()!=1){
showpricenotes=orderroomtypebean.getPricenotesaleprice();
}else{
showpricenotes=""+orderroomtypebean.getAvasaleprice();
}
orderroomtypebean.setPricenotebaseprice(showpricenotes);
orderroomtypebean.setCreateby(""+orderroomtypebean.getAvasaleprice().intValue()*orderroomtypebean.getDays()*orderroomtypebean.getRoomqty());
countPirce = countPirce + (int) orderroomtypebean.getAvasaleprice().intValue() * orderroomtypebean.getDays() * orderroomtypebean.getRoomqty();
}else if("cus".equals(cus_suptype)){
if(null==orderroomtypebean.getIsequalsaleprice() || orderroomtypebean.getIsequalsaleprice()!=1){
showpricenotes=orderroomtypebean.getPricenotesaleprice()+" 返"+((int)(orderroomtypebean.getAvasaleprice().doubleValue()-orderroomtypebean.getAvapreeprice().doubleValue()));
}else{
showpricenotes=""+orderroomtypebean.getAvasaleprice()+" 返"+((int)(orderroomtypebean.getAvasaleprice().doubleValue()-orderroomtypebean.getAvapreeprice().doubleValue()));
}
orderroomtypebean.setPricenotebaseprice(showpricenotes);
orderroomtypebean.setCreateby(""+orderroomtypebean.getAvasaleprice().intValue()*orderroomtypebean.getDays()*orderroomtypebean.getRoomqty());
countPirce = countPirce + (int) orderroomtypebean.getAvasaleprice().intValue() * orderroomtypebean.getDays() * orderroomtypebean.getRoomqty();
}
}else{
if("sup".equals(cus_suptype)){
if(null==orderroomtypebean.getIsequalbaseprice() || orderroomtypebean.getIsequalbaseprice()!=1){
showpricenotes=orderroomtypebean.getPricenotebaseprice();
}else{
showpricenotes=""+orderroomtypebean.getAvabaseprice();
}
orderroomtypebean.setPricenotebaseprice(showpricenotes);
orderroomtypebean.setCreateby(""+orderroomtypebean.getAvabaseprice().intValue()*orderroomtypebean.getDays()*orderroomtypebean.getRoomqty());
countPirce = countPirce + (int) orderroomtypebean.getAvabaseprice().intValue()*orderroomtypebean.getDays() * orderroomtypebean.getRoomqty();
}else if("cus".equals(cus_suptype)){
if(null==orderroomtypebean.getIsequalpreeprice() || orderroomtypebean.getIsequalpreeprice()!=1){
showpricenotes=orderroomtypebean.getPricenotepreeprice();
}else{
showpricenotes=""+orderroomtypebean.getAvapreeprice();
}
orderroomtypebean.setPricenotebaseprice(showpricenotes);
orderroomtypebean.setCreateby(""+orderroomtypebean.getAvapreeprice().intValue()*orderroomtypebean.getDays()*orderroomtypebean.getRoomqty());
countPirce = countPirce + (int) orderroomtypebean.getAvapreeprice().intValue()*orderroomtypebean.getDays() * orderroomtypebean.getRoomqty();
}
}
}
if(orderroomtypebean.getRoomtypenameratetype().length()>showpricenotes.length()){
priceRoomLength= orderroomtypebean.getRoomtypenameratetype().length();
}else{
priceRoomLength=showpricenotes.length();
}
noCount = noCount+ (priceRoomLength/11+1)*linHieght;
}
}
String hotelRemark = "";
if("sup".equals(cus_suptype)){
hotelRemark= order.getHotelremark();
}else{
hotelRemark=order.getMemberremark();
}
int remarkNos = hotelRemark.length()/42+1;
int imageHeight = 15 + orderroomtypebeanList.size() * linHieght + orderotherfeesList.size() * linHieght + linHieght + 10+55+(remarkNos-1)*20+noCount;
BufferedImage image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
Graphics graphicsPrice = image.getGraphics();
Font fontHead = new Font("宋体", Font.BOLD, 14);// 头部字
graphicsPrice.setFont(fontHead);
graphicsPrice.setColor(Color.WHITE);
graphicsPrice.fillRect(0, 0, imageWidth, imageHeight);
graphicsPrice.setColor(Color.BLACK);
graphicsPrice.drawLine(42, 0, 760, 0);//画线
graphicsPrice.drawString("类型", 45, 15);
graphicsPrice.drawString("内容", 150, 15);
graphicsPrice.drawString("入住日期", 242, 15);
graphicsPrice.drawString("退房日期", 310, 15);
graphicsPrice.drawString("晚数", 380, 15);
graphicsPrice.drawString("间数", 420, 15);
graphicsPrice.drawString("含早情况", 460, 15);
if (order.getPricingtype() == 11) {// 现付
graphicsPrice.drawString("现付价", 590, 15);
} else {
graphicsPrice.drawString("挂帐价", 590, 15);
}
graphicsPrice.drawString("小计", 715, 15);
graphicsPrice.drawLine(42, 20, 760, 20);//画线
Font fontContent = new Font("宋体", Font.PLAIN, 14);// 头部字
graphicsPrice.setFont(fontContent);
int noY = 15;// 当前开始写的y坐标
int priceRoomLength=0;//最长的字体长度
int rowLength=1;//行数
String latestarrivaltime="";//到店时间
if (null != orderroomtypebeanList) {
Orderroomtypebean orderroomtypebean;
for (int i = 0; i < orderroomtypebeanList.size(); i++) {
orderroomtypebean = (Orderroomtypebean) orderroomtypebeanList.get(i);
noY = noY + linHieght;
//orderroomtypebean.setRoomtypenameratetype("标单(含单早)K JFDKJF");//房型
//orderroomtypebean.setRoomtypenameratetype("李停,张莫大李世大刘新好不成因为莫成好李成莫金大中胡涛水");//房型
//orderroomtypebean.setPricenotebaseprice("9月4日490,9月5日500,9月6日510");//价格字段
/*int roomtypeX=90;
if(orderroomtypebean.getRoomtypenameratetype().length()>11){
//orderroomtypebean.setRoomtypenameratetype(orderroomtypebean.getRoomtypenameratetype().substring(0,11));
}
if(orderroomtypebean.getRoomtypenameratetype().length()<4){
roomtypeX=120;
}else if(orderroomtypebean.getRoomtypenameratetype().length()<8){
roomtypeX=100;
}else {
roomtypeX=90;
}
*/
orderType=orderType.replace("预订", "");
graphicsPrice.drawString(orderType.substring(0,orderType.length()-1), 46, noY);
graphicsPrice.drawString(CommonUtil.getDateString(orderroomtypebean.getCheckindate(), "M月d日"),245, noY);
graphicsPrice.drawString(CommonUtil.getDateString(orderroomtypebean.getCheckoutdate(), "M月d日"), 320, noY);
graphicsPrice.drawString(orderroomtypebean.getDays()+"晚", 386, noY);
graphicsPrice.drawString(orderroomtypebean.getRoomqty()+"间 ", 425, noY);
graphicsPrice.drawString(orderroomtypebean.getCreateby(), 710, noY);
/*
Map map=new HashMap();
OrderroomtypepriceDao orderroomtypepriceDao=(OrderroomtypepriceDao) Framework.getDaoFactory().getBean("orderroomtypepriceDao");
int breakfast=10;
if(orderroomtypebean.getServicerate().intValue()==1){//该BEAN的所有PRICE 都为是一样的。
breakfast=orderroomtypebean.getIncludebreakfastqty2();
}else{
map.put("orderroomtypebeanid", orderroomtypebean.getOrderroomtypebeanid());
map.put("sortString", "includebreakfastqty2,night");
List pricelist=orderroomtypepriceDao.queryOrderroomtypeprices(map);
Orderroomtypeprice price=null;
for(int n=0;n<pricelist.size();n++){
price=(Orderroomtypeprice)pricelist.get(n);
}
}
*/
graphicsPrice.drawString(OptionManager.getNameByCode(OptionType.inbreakfast, "" + orderroomtypebean.getIncludebreakfastqty2()), 476, noY);
//graphicsPrice.drawString(orderroomtypebean, 476, noY);
//latestarrivaltime = orderroomtypebean.getLatestarrivaltime();
//graphicsPrice.drawString(orderroomtypebean.getLatestarrivaltime(), 450, noY);
/*
* if(order.getPricingtype()==11){//现付
* if(orderroomtypebean.getIsequalsaleprice()==1){
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getAvasaleprice()),
* 675, noY); }else{
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getPricenotesaleprice()),
* 675, noY); }
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getAvasaleprice()*orderroomtypebean.getDays()*orderroomtypebean.getRoomqty()),
* 745, noY); }else{
* if(orderroomtypebean.getIsequalbaseprice()==1){
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getAvabaseprice()),
* 675, noY); }else{
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getPricenotebaseprice()),
* 675, noY); }
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getAvabaseprice()*orderroomtypebean.getDays()*orderroomtypebean.getRoomqty()),
* 745, noY); }
*/
/*
if("1".equals(isprotocol)){
graphicsPrice.drawString("协议价", 535, noY);//现付价
graphicsPrice.drawString("协议价", 680, noY);//现付价
}else{
if (order.getPricingtype().intValue() == 11) {// 现付
graphicsPrice.drawString("RMB "+(int) orderroomtypebean.getAvasaleprice().intValue(), 530, noY);//现付价
graphicsPrice.drawString(CommonUtil.getDefault((int) orderroomtypebean.getAvasaleprice().intValue() * orderroomtypebean.getDays()* orderroomtypebean.getRoomqty()), 700, noY);//现付合计
countPirce = countPirce + (int) orderroomtypebean.getAvasaleprice().intValue() * orderroomtypebean.getDays() * orderroomtypebean.getRoomqty();
} else {
graphicsPrice.drawString(order.getCurrency()+" "+(int) orderroomtypebean.getAvabaseprice().intValue(), 530, noY);//底价
graphicsPrice.drawString(CommonUtil.getDefault((int) orderroomtypebean.getAvabaseprice().intValue() * orderroomtypebean.getDays()* orderroomtypebean.getRoomqty()),700, noY);
countPirce = countPirce + (int) orderroomtypebean.getAvabaseprice().intValue() * orderroomtypebean.getDays() * orderroomtypebean.getRoomqty();
}
}*/
if(orderroomtypebean.getRoomtypenameratetype().length()>orderroomtypebean.getPricenotebaseprice().length()){
priceRoomLength= orderroomtypebean.getRoomtypenameratetype().length();
}else{
priceRoomLength=orderroomtypebean.getPricenotebaseprice().length();
}
int rows =0;
String [] showroomtypes=StringsUtil.splitByindex(orderroomtypebean.getRoomtypenameratetype(),10);
String [] showprices=StringsUtil.splitByindex(orderroomtypebean.getPricenotebaseprice(),23);
if(showroomtypes.length>showprices.length){
rows=showroomtypes.length;
}else{
rows=showprices.length;
}
for(int jj=0;jj<rows;jj++){
if(jj<=showroomtypes.length-1){
if(showroomtypes.length==1 && showroomtypes[jj].length()<3){
graphicsPrice.drawString(showroomtypes[jj], 130, noY);
}else if(showroomtypes.length==1 && showroomtypes[jj].length()<6){
graphicsPrice.drawString(showroomtypes[jj], 110, noY);
}else{
graphicsPrice.drawString(showroomtypes[jj], 90, noY);
}
}
if(jj<=showprices.length-1){
if(showprices.length==1 && showprices[jj].length()<7){
graphicsPrice.drawString(showprices[jj], 580, noY);
}else if(showprices.length==1 && showprices[jj].length()<14){
graphicsPrice.drawString(showprices[jj], 550, noY);
}else{
graphicsPrice.drawString(showprices[jj], 530, noY);
}
}
if(jj==rows-1){
}else{
noY=noY+linHieght;
}
}
graphicsPrice.drawLine(42, noY+5, 760, noY+5);//画线
}
}
//画竖线
graphicsPrice.drawLine(240, 0, 240, noY+5);//入住
graphicsPrice.drawLine(305, 0, 305, noY+5);//退房日期
graphicsPrice.drawLine(375, 0, 375, noY+5);//晚数
graphicsPrice.drawLine(415, 0, 415, noY+5);//间数
graphicsPrice.drawLine(455, 0, 455, noY+5);//晚数
double sumprice = 0;
graphicsPrice.setFont(fontContent);
if (null != orderotherfeesList) {
Orderotherfees orderotherfees;
for (int i = 0; i < orderotherfeesList.size(); i++) {
orderotherfees = (Orderotherfees) orderotherfeesList.get(i);
sumprice = sumprice + orderotherfees.getTotalamount();
String otherfeeString="";
String begindates="";
String enddates="";
String dates="";
begindates=CommonUtil.getDateString(orderotherfees.getBegindate(), "M月d日");
if(null==orderotherfees.getEnddate()){
dates=begindates;
}else{
enddates=CommonUtil.getDateString(orderotherfees.getEnddate(), "M月d日");
dates=begindates+"~"+enddates;
}
otherfeeString=otherfeeString+dates;
if (orderotherfees.getFeetype().intValue() == 2) {//早餐
otherfeeString=otherfeeString+" 加"+OptionManager.getNameByCode(OptionType.breaktype, "" + orderotherfees.getBreakfasttype())+" ";
} else {//加床
otherfeeString=otherfeeString+" 加床 ";
}
//otherfeeString=otherfeeString+order.getCurrency()+" "+orderotherfees.getBaseprice()+" * "+orderotherfees.getAmount()+" 份 ";
if(null!=orderType && orderType.length()>2){
orderType=orderType.substring(0,orderType.length()-1);
}
noY = noY + linHieght;
graphicsPrice.drawString(orderType, 45, noY);
graphicsPrice.drawString(otherfeeString, 111, noY);
graphicsPrice.drawString(order.getCurrency()+" "+orderotherfees.getBaseprice()+" * "+orderotherfees.getAmount()+" 份 ", 535, noY);
graphicsPrice.drawString(CommonUtil.getDefault(orderotherfees.getCompanyid()), 700, noY);
graphicsPrice.drawLine(42, noY+5, 760, noY+5);//画线
}
}
if("1".equals(isprotocol)){
graphicsPrice.drawString("协议价", 710, noY + linHieght);
}else{
graphicsPrice.drawString(countPirce + sumprice + "", 700, noY + linHieght);
}
graphicsPrice.drawString("总计("+order.getCurrency()+"):", 580, noY + linHieght);
//下面信息
graphicsPrice.setFont(fontHead);
graphicsPrice.drawString("到店时间:", 40, noY+linHieght+linHieght);
graphicsPrice.drawString(latestarrivaltime, 110, noY+linHieght+linHieght);
if("sup".equals(cus_suptype)){
graphicsPrice.drawString("确认号:", 170, noY+linHieght+linHieght);
graphicsPrice.drawString(null==order.getConfirmno()?"":order.getConfirmno(), 225, noY+linHieght+linHieght);
}
graphicsPrice.drawString("备注信息:", 40, noY+linHieght+linHieght+20);
//graphicsPrice.drawString(order.getHotelremark(), 110, noY+linHieght+linHieght+20);//备注信息
if(remarkNos>1){
int rnoy = noY+linHieght+linHieght+20;
int i=0;
while(i<=remarkNos-1){
graphicsPrice.drawString(hotelRemark.substring(i*43,(i*43+43)>=hotelRemark.length()?hotelRemark.length():(i*43+43)), 110, rnoy);//备注信息
graphicsPrice.drawLine(110, rnoy+5, 760, rnoy+5);//横线
rnoy+=20;
i++;
}
}else{
graphicsPrice.drawString(hotelRemark, 110, noY+linHieght+linHieght+20);//备注信息
graphicsPrice.drawLine(110, noY+linHieght+linHieght+20+5, 760, noY+linHieght+linHieght+20+5);//横线
}
//画竖线
graphicsPrice.drawLine(85, 0, 85, noY+5);//房型
graphicsPrice.drawLine(42, 0, 42, noY+linHieght+5);//画开始线
graphicsPrice.drawLine(525, 0, 525, noY+5);//含早情况
graphicsPrice.drawLine(695, 0, 695, noY+linHieght+5);//结算价
graphicsPrice.drawLine(760, 0, 760, noY+linHieght+5);//画结束线
graphicsPrice.drawLine(42, noY+linHieght+5, 760, noY+linHieght+5);//最后横线
return image;
}
public static String createTiffImageByFileName(String filepath) throws Java91Exception{
String filepath_tif="";
if(null != filepath && filepath.length()>0){
String filepath_tiff = filepath.substring(0,filepath.lastIndexOf("."))+".tif";
try{
String filename_jpg= filepath.substring(filepath.lastIndexOf(File.separator)+1,filepath.length());
String filename_tif = filepath_tiff.substring(filepath_tiff.lastIndexOf(File.separator)+1,filepath_tiff.length());
//System.out.println("22222222222222222"+filepath);
//System.out.println("444444"+filepath_tiff);
//System.out.println("444444"+filename_jpg);
//System.out.println("444444"+filename_tif);
boolean isUp = FtpManager.put("FaxDec"+File.separator+filename_jpg, filepath);
if(isUp){//如果上传成功
//执行调用 jpg转tif文件
HttpRequester request = new HttpRequester();
request.setDefaultContentEncoding("utf-8");
//HttpRespons hr = request.sendGet("http://localhost:8080/Fax/FaxServlet?fileName="+fileNames);//上传成功后调用转tiff命令
//System.out.println(Java91Config.jpg2tifservlet+"?fileName="+filename_jpg);
HttpRespons hr = request.sendGet(Java91Config.jpg2tifservlet+"?fileName="+filename_jpg);//上传成功后调用转tiff命令
// System.out.println(hr.getContent());
if(null !=hr.getContent() && hr.getContent().length()>0){
//System.out.println("33333333333333"+File.separator+filename_tif);
filepath_tif = FtpManager.downFile("FaxDec"+File.separator+filename_tif);
}
}
}catch (Exception e){
e.printStackTrace();
throw new Java91Exception("创建TIF文件错误!请与管理员联系,确认图片服务器正常");
}
}
return filepath_tif;
}
//创建订单传真图片-供应商
public static String createOrderFaxPictureByCustomer(String bascDec, String barcode, String resultSrc, User user, Order order, List orderroomtypebeanList, List orderotherfeesList,
String orderType) {
if (null == user || null == order || null == orderroomtypebeanList || orderroomtypebeanList.size()<=0 || null == orderType || orderType.length()<=0)
return null;
String isprotocol="8";
try {
String pers = order.getCheckinpersons();
//String pers = "保钓委执委曾健成说,他们首选是从香港出发前往钓鱼岛宣示主权,但由于担心受到阻挠,因此,他们同时也拟定从台湾出发的方案。但最后从哪里出发,无明确说明。";
int perno = pers.length()/45+1;
BufferedImage imageHead = new BufferedImage(imageWidth, 250+(perno-1)*15+10, BufferedImage.TYPE_INT_RGB);
String barCodeDic= ImageFaxUtil.createBarcodeImage(bascDec, barcode);//条形码图片
File logofile = new File(Framework.servletRealPath+"faxFile"+File.separator+ "logo.jpg");
Image logoImage = javax.imageio.ImageIO.read(logofile); // 读取jpg等图片文件
InputStream barCodeStream = new FileInputStream(bascDec + barCodeDic);
BufferedImage barCodeImage = ImageIO.read(barCodeStream);
Graphics graphics = imageHead.getGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, imageWidth, 250+(perno-1)*15+10);
graphics.setColor(Color.BLACK);
graphics.drawImage(logoImage, 75, 30, null);
graphics.drawImage(barCodeImage, 560, 30, null);
graphics.setFont(fontPage);// 设置当前图片全局字体
graphics.drawLine(20, 129, 800, 129);//画线
//黑体 隶书 华文楷体
graphics.setFont(new Font("宋体",Font.BOLD, 15));//普通字体
//graphics.drawString(CommonUtil.getDefault(order.getHotelname())+" 订房部", 75, 185);// 酒店的名字
graphics.drawString(CommonUtil.getDefault(order.getCustomername())+" "+order.getMembername(), 75, 185);// 酒店的名字
//graphics.setFont(fontPage);// 设置当前图片全局字体
graphics.drawLine(45, 190, 295, 190);//画线
graphics.drawString(order.getHotelname(), 110, 205);
graphics.drawLine(45, 210, 280, 210);//画线
String pricingtype="";
if(order.getPricingtype().intValue() == 11 ){
pricingtype="客人前台现付";
}else{
if(order.getOrherhang().intValue()==1){
pricingtype="房费挂帐,杂费可挂帐";
}else{
pricingtype="房费挂帐,杂费客人自理";
}
}
graphics.drawString(pricingtype, 110, 230);
graphics.setFont(new Font("宋体",Font.PLAIN, 13));//普通字体
graphics.drawString("深圳市捷旅国际旅行社有限公司 www.jl-tour.com", 100, 110);
graphics.drawString("发送人/工号:", 50, 126);
graphics.drawString(user.getRealname()+"/"+user.getUsercd(), 135, 126);
graphics.drawString("电话:", 200, 126);
graphics.drawString(jltourPhoto, 236, 126);
graphics.drawString("传真:", 370, 126);
graphics.drawString(jltourFax, 402, 126);
graphics.drawString("发送时间:", 530, 126);
graphics.drawString(CommonUtil.getDateString(new java.util.Date(), "yyyy-MM-dd HH:mm"), 590, 126);
graphics.drawString("致:", 45, 185);
graphics.drawString("酒店名称:", 45, 205);// 酒店的名字
graphics.drawString("结算方式:", 45, 230);
graphics.drawString("客人姓名:", 45, 250);
graphics.setFont(new Font("宋体", Font.BOLD, 14));
graphics.drawLine(45, 235, 295, 235);//画线
int noys=250;
int test=0;
int i=0;
if(perno>1){
while(i<perno){
test = (((i)*45+45)>=pers.length())?pers.length():((i)*45+45-1);
graphics.drawString(pers.substring((i)*45,test), 105, noys);
noys = noys+15;
i++;
}
}else{
graphics.drawString(pers, 105, 250);
}
graphics.drawString("订单编号:", 600, 152);
graphics.drawString(order.getOrdercd(), 665, 152);
Font fontTitle = new Font("黑体", Font.BOLD, 20);
graphics.setFont(fontTitle);
graphics.drawString(orderType, 235, 155);
//BufferedImage bg_src = ImageFaxUtil.createBaseHeadBufImage(bascDec, ImageFaxUtil.createBarcodeImage(bascDec, barcode), user.getUsercd()+"/"+user.getRealname(), orderType, order);
BufferedImage bi_pricesrc = ImageFaxUtil.createImagePrice(orderroomtypebeanList, orderotherfeesList, orderType, order,"8","cus");
//File logofile = new File(Framework.servletRealPath+"faxFile\\"+ baseBottomFile);
//Image logo_src = javax.imageio.ImageIO.read(logofile); // 读取最下面的文件
//BufferedImage bottom =ImageFaxUtil.createImageBottom();
int bg_width = imageHead.getWidth(null);
int bg_height = imageHead.getHeight(null);
//int logo_width = bottom.getWidth(null);
//int logo_height = bottom.getHeight(null);
int bi_width = bi_pricesrc.getWidth(null);
int bi_height = bi_pricesrc.getHeight(null);
BufferedImage imgage = new BufferedImage(imageWidth, bg_height + bi_height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = imgage.createGraphics();
g2d.drawImage(imageHead, 0, 0, bg_width, bg_height, null);
// 组合价格
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 1.0f)); // 透明度设置开始
g2d.drawImage(bi_pricesrc, 0, bg_height, bi_width, bi_height, null);
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); // 透明度设置
// 结束
// 组合下面
//g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 1.0f)); // 透明度设置开始
//g2d.drawImage(bottom, 0, bg_height + bi_height, logo_width, logo_height, null);
//g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); // 透明度设置
// 结束
//图片黑白
//ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
//ColorConvertOp op = new ColorConvertOp(cs, null);
// imgage = op.filter(imgage, null);
FileOutputStream out = new FileOutputStream(Framework.servletRealPath+Java91Config.getFaxImageTempPath()+File.separator + resultSrc);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(imgage);
out.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
}
return resultSrc;
}
//供应商 订单传真 价格
public static BufferedImage createImagePriceByCustomer(List orderroomtypebeanList, List orderotherfeesList, String orderType, Order order) {
int imageHeight = 15 + orderroomtypebeanList.size() * linHieght + orderotherfeesList.size() * linHieght + linHieght + 10;
BufferedImage image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
Graphics graphicsPrice = image.getGraphics();
Font fontHead = new Font("宋体", Font.BOLD, 14);// 头部字
graphicsPrice.setFont(fontHead);
graphicsPrice.setColor(Color.WHITE);
graphicsPrice.fillRect(0, 0, imageWidth, imageHeight);
graphicsPrice.setColor(Color.BLACK);
graphicsPrice.drawString("类型", 15, 15);
graphicsPrice.drawString("房型", 65, 15);
graphicsPrice.drawString("入住/退房日期", 180, 15);
graphicsPrice.drawString("含早情况", 330, 15);
graphicsPrice.drawString("最晚到店", 450, 15);
if (order.getPricingtype() == 11) {// 现付
graphicsPrice.drawString("现付价", 555, 15);
} else {
graphicsPrice.drawString("结算价", 555, 15);
}
graphicsPrice.drawString("小计", 745, 15);
Font fontContent = new Font("楷体", Font.PLAIN, 14);// 头部字
graphicsPrice.setFont(fontContent);
int noY = 15;// 当前开始写的y坐标
double countPirce = 0;
if (null != orderroomtypebeanList) {
Orderroomtypebean orderroomtypebean,orderroomtypebeantemp;
for (int i = 0; i < orderroomtypebeanList.size(); i++) {
orderroomtypebean = (Orderroomtypebean) orderroomtypebeanList.get(i);
if(0!=orderroomtypebean.getOrderroomtypebeanidedit()){
continue;
}
String beantitle="";
Integer optiontype=orderroomtypebean.getOpttype().intValue();
if(0==optiontype){
if(orderroomtypebean.getHotelconfirmstatus().intValue()==1){
beantitle="已确认";
}else{
if(0!=orderroomtypebean.getOrderroomtypebeanidorg().intValue()){
for (int f = 0; f < orderroomtypebeanList.size();f++) {
orderroomtypebeantemp = (Orderroomtypebean) orderroomtypebeanList.get(f);
if(orderroomtypebeantemp.getOrderroomtypebeanid().intValue()==orderroomtypebean.getOrderroomtypebeanidorg().intValue()){
int optiontype2=orderroomtypebeantemp.getOpttype().intValue();
if(optiontype2==10){
beantitle="改价格";
}else if(optiontype2==11){
beantitle="减少间夜";
}else if(optiontype2==12){
beantitle="改房型";
}else if(optiontype2==13){
beantitle="撤消";
}
break;
}
}
}else{
beantitle="新订";
}
}
}else if(optiontype==10){
beantitle="价格修改";
}else if(optiontype==11){
beantitle="减少间夜数";
}else if(optiontype==12){
beantitle="修改房型";
}else if(optiontype==13){
beantitle="撤消房型";
}
noY = noY + linHieght;
graphicsPrice.drawString(beantitle, 15, noY);
graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getRoomtypenameratetype()), 65, noY);
graphicsPrice.drawString(CommonUtil.getDateString(orderroomtypebean.getCheckindate(), "M月d日")+"~"+CommonUtil.getDateString(orderroomtypebean.getCheckoutdate(), "M月d日")+" "+orderroomtypebean.getRoomqty()+"间 "+orderroomtypebean.getDays()+"晚", 150, noY);
Map map=new HashMap();
OrderroomtypepriceDao orderroomtypepriceDao=(OrderroomtypepriceDao) Framework.getDaoFactory().getBean("orderroomtypepriceDao");
int breakfast=10;
if(orderroomtypebean.getServicerate().intValue()==1){//该BEAN的所有PRICE 都为是一样的。
breakfast=orderroomtypebean.getIncludebreakfastqty2();
}else{
map.put("orderroomtypebeanid", orderroomtypebean.getOrderroomtypebeanid());
map.put("sortString", "includebreakfastqty2,night");
List pricelist=orderroomtypepriceDao.queryOrderroomtypeprices(map);
Orderroomtypeprice price=null;
for(int n=0;n<pricelist.size();n++){
price=(Orderroomtypeprice)pricelist.get(n);
}
}
graphicsPrice.drawString(OptionManager.getNameByCode(OptionType.inbreakfast, "" + orderroomtypebean.getIncludebreakfastqty2()), 330, noY);
graphicsPrice.drawString(orderroomtypebean.getLatestarrivaltime(), 450, noY);
/*
* if(order.getPricingtype()==11){//现付
* if(orderroomtypebean.getIsequalsaleprice()==1){
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getAvasaleprice()),
* 675, noY); }else{
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getPricenotesaleprice()),
* 675, noY); }
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getAvasaleprice()*orderroomtypebean.getDays()*orderroomtypebean.getRoomqty()),
* 745, noY); }else{
* if(orderroomtypebean.getIsequalbaseprice()==1){
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getAvabaseprice()),
* 675, noY); }else{
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getPricenotebaseprice()),
* 675, noY); }
* graphicsPrice.drawString(CommonUtil.getDefault(orderroomtypebean.getAvabaseprice()*orderroomtypebean.getDays()*orderroomtypebean.getRoomqty()),
* 745, noY); }
*/
if (order.getPricingtype().intValue() == 11) {// 现付
graphicsPrice.drawString("RMB "+(int) orderroomtypebean.getAvasaleprice().intValue(), 555, noY);//现付价
graphicsPrice.drawString(CommonUtil.getDefault((int) orderroomtypebean.getAvasaleprice().intValue() * orderroomtypebean.getDays()* orderroomtypebean.getRoomqty()), 745, noY);//现付合计
countPirce = countPirce + (int) orderroomtypebean.getAvasaleprice().intValue() * orderroomtypebean.getDays() * orderroomtypebean.getRoomqty();
} else {
graphicsPrice.drawString("RMB "+(int) orderroomtypebean.getAvapreeprice().intValue(), 555, noY);//底价
graphicsPrice.drawString(CommonUtil.getDefault((int) orderroomtypebean.getAvapreeprice().intValue() * orderroomtypebean.getDays()* orderroomtypebean.getRoomqty()), 745, noY);
countPirce = countPirce + (int) orderroomtypebean.getAvapreeprice().intValue() * orderroomtypebean.getDays() * orderroomtypebean.getRoomqty();
}
}
}
double sumprice = 0;
graphicsPrice.setFont(fontContent);
if (null != orderotherfeesList) {
Orderotherfees orderotherfees;
for (int i = 0; i < orderotherfeesList.size(); i++) {
orderotherfees = (Orderotherfees) orderotherfeesList.get(i);
sumprice = sumprice + orderotherfees.getTotalamount();
String otherfeeString="";
String begindates="";
String enddates="";
String dates="";
begindates=CommonUtil.getDateString(orderotherfees.getBegindate(), "M月d日");
if(null==orderotherfees.getEnddate()){
dates=begindates;
}else{
enddates=CommonUtil.getDateString(orderotherfees.getEnddate(), "M月d日");
dates=begindates+"~"+enddates;
}
otherfeeString=otherfeeString+dates;
if (orderotherfees.getFeetype().intValue() == 2) {//早餐
otherfeeString=otherfeeString+" 加"+OptionManager.getNameByCode(OptionType.breaktype, "" + orderotherfees.getBreakfasttype())+" ";
} else {//加床
otherfeeString=otherfeeString+" 加床 ";
}
//otherfeeString=otherfeeString+order.getCurrency()+" "+orderotherfees.getBaseprice()+" * "+orderotherfees.getAmount()+" 份 ";
if(null!=orderType && orderType.length()>2){
orderType=orderType.substring(0,orderType.length()-1);
}
noY = noY + linHieght;
graphicsPrice.drawString(orderType, 15, noY);
graphicsPrice.drawString(otherfeeString, 150, noY);
graphicsPrice.drawString("RMB "+orderotherfees.getUnitprice()+" * "+orderotherfees.getAmount()+" 份 ", 555, noY);
graphicsPrice.drawString(CommonUtil.getDefault(orderotherfees.getTotalamount()), 745, noY);
}
}
graphicsPrice.drawString("总计(RMB):", 655, noY + linHieght);
graphicsPrice.drawString(countPirce + sumprice + "", 745, noY + linHieght);
return image;
}
public static String createDailyauditFaxPicture(String bascDec, String barcode, User user, String resultSrc, List orderitemList, Map orderitemsizeMap,
Map orderitemidDateStatusMap, Dailyauditstatus dailyauditstatus) {
if (null == user || null == bascDec || null == barcode || null == resultSrc || null == orderitemList || null == orderitemsizeMap || null == orderitemidDateStatusMap
|| null == dailyauditstatus)
return null;
try {
BufferedImage bg_src = ImageFaxUtil.createBaseHeadDayBufImageNew(bascDec, ImageFaxUtil.createBarcodeImage(bascDec, barcode), user, "日审单", dailyauditstatus);
BufferedImage bi_pricesrc = ImageFaxUtil.createImageDayPriceNew(orderitemList, orderitemsizeMap, orderitemidDateStatusMap, dailyauditstatus);
//BufferedImage bg_src = ImageFaxUtil.createBaseHeadDayBufImage(bascDec, ImageFaxUtil.createBarcodeImage(bascDec, barcode), userName, "日审单", dailyauditstatus);
//BufferedImage bi_pricesrc = ImageFaxUtil.createImageDayPrice(orderitemList, orderitemsizeMap, orderitemidDateStatusMap, dailyauditstatus);
BufferedImage bottomImage = ImageFaxUtil.createDailyauditImageBottom();
int bg_width = bg_src.getWidth(null);
int bg_height = bg_src.getHeight(null);
int bi_width = bi_pricesrc.getWidth(null);
int bi_height = bi_pricesrc.getHeight(null);
int bottom_height = bottomImage.getHeight(null);
BufferedImage imgage = new BufferedImage(bg_width, bg_height + bi_height+bottom_height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = imgage.createGraphics();
g2d.drawImage(bg_src, 0, 0, bg_width, bg_height, null);
// 组合价格
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 1.0f)); // 透明度设置开始
g2d.drawImage(bi_pricesrc, 0, bg_height, bi_width, bi_height, null);
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); // 透明度设置
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 1.0f)); // 透明度设置开始
g2d.drawImage(bottomImage, 0, bi_height+bg_height, bi_width,bottom_height, null);
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); // 透明度设置
//图片黑白
//ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
//ColorConvertOp op = new ColorConvertOp(cs, null);
//imgage = op.filter(imgage, null);
FileOutputStream out = new FileOutputStream(Framework.servletRealPath+Java91Config.getFaxImageTempPath()+File.separator + resultSrc);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(imgage);
out.close();
} catch (IOException e) {
e.printStackTrace();
return null;
}
return resultSrc;
}
// 供应商 订单底图
public static BufferedImage createDailyauditImageBottom() {
BufferedImage image = new BufferedImage(imageWidth,220, BufferedImage.TYPE_INT_RGB);
Graphics graphics = image.getGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, imageWidth, 220);
graphics.setColor(Color.BLACK);
graphics.setFont(fontPage);// 设置当前图片全局字体
graphics.drawString("TO:各大酒店销售部", 15, 10);
graphics.drawString("FR:深圳捷旅假期", 15, 30);
graphics.drawString("×××以上是我社入住贵酒店房态查询表,请填写入住房间号码,若已退房客房请备注退房时间。未到店请写未到,登记入住客人并非", 30, 50);
graphics.drawString("预定名字,请注明登记客人名字;续住一些特殊情况,请在房态表上注明,如果客人是入住当天退房,请备注有无返佣并请尽快回传,", 30, 70);
graphics.drawString("谢谢。", 30, 90);
graphics.drawLine(30, 125, 150, 125);//画线
graphics.drawString("请签名确认", 160, 125);
graphics.drawString("请回传 33389800 或 33396877", 30, 145);
graphics.drawString("电话:0755-33394811 ", 30, 165);
graphics.drawString("*******非常感谢*******", 30, 185);
graphics.drawString("晚上请打3339777 按 1 麻烦请尽快回传,谢谢", 30, 205);
return image;
}
public static BufferedImage createBaseHeadDayBufImageNew(String bascDec, String barCodeDic,User user, String title, Dailyauditstatus dailyauditstatus) throws IOException {
BufferedImage imageHead = new BufferedImage(imageWidth, 210, BufferedImage.TYPE_INT_RGB);
File logofile = new File(Framework.servletRealPath+"faxFile"+File.separator+ "logo.jpg");
Image logoImage = javax.imageio.ImageIO.read(logofile); // 读取jpg等图片文件
InputStream barCodeStream = new FileInputStream(bascDec + barCodeDic);
BufferedImage barCodeImage = ImageIO.read(barCodeStream);
Graphics graphics = imageHead.getGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, imageWidth, 210);
graphics.setColor(Color.BLACK);
graphics.drawImage(logoImage, 75, 30, null);
graphics.drawImage(barCodeImage, 560, 30, null);
graphics.setFont(fontPage);// 设置当前图片全局字体
graphics.drawLine(20, 129, 800, 129);//画线
//黑体 隶书 华文楷体
graphics.setFont(new Font("宋体",Font.BOLD, 15));//普通字体
graphics.drawString(CommonUtil.getDefault(dailyauditstatus.getSuppliername()), 75, 185);//供应商名字
graphics.drawString("订单信息栏:", 45, 205);
graphics.setFont(new Font("宋体",Font.PLAIN, 13));//普通字体
graphics.drawString("深圳市捷旅国际旅行社有限公司 www.jl-tour.com", 100, 110);
graphics.drawString("发送人/工号:", 50, 126);
graphics.drawString(user.getRealname()+"/"+user.getUsercd(), 135, 126);
graphics.drawString("电话:", 200, 126);
graphics.drawString(jltourPhoto, 236, 126);
graphics.drawString("传真:", 370, 126);
graphics.drawString(jltourFax, 402, 126);
graphics.drawString("发送时间:", 530, 126);
graphics.drawString(CommonUtil.getDateString(new java.util.Date(), "yyyy-MM-dd HH:mm"), 590, 126);
graphics.drawString("致:", 45, 185);
graphics.drawString("请确认 "+CommonUtil.getDateString(dailyauditstatus.getNight(),"M月d日")+" 的入住情况", 145, 205);
graphics.setFont(new Font("宋体", Font.BOLD, 14));
Font fontTitle = new Font("黑体", Font.BOLD, 20);
graphics.setFont(fontTitle);
graphics.drawString(title, 235, 155);
return imageHead;
}
public static BufferedImage createBaseHeadDayBufImage(String bascDec, String barCodeDic, String userName, String title, Dailyauditstatus dailyauditstatus) throws IOException {
BufferedImage imageHead = new BufferedImage(imageWidth, 145, BufferedImage.TYPE_INT_RGB);
File logofile = new File(Framework.servletRealPath+"faxFile"+File.separator+ "logo.jpg");
Image logoImage = javax.imageio.ImageIO.read(logofile); // 读取jpg等图片文件
InputStream barCodeStream = new FileInputStream(bascDec + barCodeDic);
BufferedImage barCodeImage = ImageIO.read(barCodeStream);
Graphics graphics = imageHead.getGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, imageWidth, 210);
graphics.setColor(Color.BLACK);
graphics.drawImage(logoImage, 0, 0, null);
graphics.drawImage(barCodeImage, 320, 0, null);
graphics.setFont(fontPage);// 设置当前图片全局字体
graphics.drawString("携旅电话:", 615, 10);// photo
graphics.drawString(jltourPhoto, 680, 10);// photo
graphics.drawString("携旅传真:", 615, 30);// photo
graphics.drawString(jltourFax, 680, 30);// fax
graphics.drawString("发送人:", 628, 50);// photo
graphics.drawString(CommonUtil.getDefault(userName), 680, 50);// 发送人
graphics.drawString("发送时间:", 615, 100);// 携旅订单号
graphics.drawString(CommonUtil.getDateString(new java.util.Date(), "yyyy-MM-dd HH:mm"), 680, 100);// 携旅订单号
graphics.setFont(new Font("宋体", Font.BOLD, 15));
graphics.drawString("致:", 15, 110);// 酒店的名字
graphics.drawString(CommonUtil.getDefault(dailyauditstatus.getSuppliername())+" ", 40, 110);// 酒店的名字
graphics.setFont(new Font("宋体", Font.BOLD, 13));
graphics.drawString("订单信息栏 请确认"+CommonUtil.getDateString(dailyauditstatus.getNight(), "M月d日")+"的入住情况", 15, 130);// 备注信息
graphics.drawLine(15, 138, 800, 138);//画线
Font fontTitle = new Font("宋体", Font.BOLD, 24);
graphics.setFont(fontTitle);
graphics.drawString("日审单", 345, 90);
return imageHead;
// InputStream imagein = new FileInputStream(Framework.servletRealPath+"faxFile\\"+ baseHeadDayFile);
// InputStream imagein2 = new FileInputStream(bascDec +barCodeDic);
// BufferedImage image = ImageIO.read(imagein);
// BufferedImage image2 = ImageIO.read(imagein2);
// Graphics graphics = image.getGraphics();
// graphics.drawImage(image2, 320, 10, null);
// graphics.setColor(Color.BLACK);
// graphics.setFont(fontPage);// 设置当前图片全局字体
// graphics.drawString(jltourPhoto, 680, 20);// photo
// graphics.drawString(jltourFax, 680, 40);// fax
// graphics.drawString(CommonUtil.getDefault(userName), 680, 60);// 发送人
// // graphics.drawString(CommonUtil.getDefault(order.getOrdercd()), 680,
// // 80);//携旅订单号
// graphics.drawString(CommonUtil.getDateString(new java.util.Date(), "yyyy-MM-dd HH:mm"), 680, 130);// 发送时间
// graphics.drawString(CommonUtil.getDefault(dailyauditstatus.getSuppliername()), 50, 130);// 酒店的名字
// // graphics.drawString(CommonUtil.getDefault(dailyauditstatus.get), 78,
// // 211);//结算方式
// Font fontTitle = new Font("宋体", Font.BOLD, 24);
// graphics.setFont(fontTitle);
// graphics.drawString(title, 360, 100);
// imagein.close();
// imagein2.close();
// return image;
}
public static BufferedImage createImageDayPrice(List orderitemList, Map orderitemsizeMap, Map orderitemidDateStatusMap, Dailyauditstatus dailyauditstatus) {
int imageHeight = 25+25+orderitemList.size()*25;
//int imageHeight = 800;
OrderDao orderDao=(OrderDao)Framework.getDaoFactory().getBean("orderDao");
Order order=null;
BufferedImage image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
Graphics graphicsPrice = image.getGraphics();
Font fontHead = new Font("宋体", Font.BOLD, 14);// 头部字
graphicsPrice.setFont(fontHead);
graphicsPrice.setColor(Color.WHITE);
graphicsPrice.fillRect(0, 0, imageWidth, imageHeight);
graphicsPrice.setColor(Color.BLACK);
graphicsPrice.drawString("订单编号", 20, 20);
graphicsPrice.drawString("房型", 130, 20);
graphicsPrice.drawString("入住/退房日期", 200, 20);
graphicsPrice.drawString("房号", 310, 20);
graphicsPrice.drawString("入住人", 350, 20);
graphicsPrice.setFont(new Font("楷体", Font.PLAIN, 13));
int beginwite = 380;
if (null != dailyauditstatus) {
Date startdate = (Date) DateUtil.getDate(dailyauditstatus.getNight(), -2);
Date currentDate = startdate;
int days = 6;
for (int g = 0; g < 3; g++) {
if(currentDate.getTime()==dailyauditstatus.getNight().getTime()){
graphicsPrice.setColor(Color.gray);
}else{
graphicsPrice.setColor(Color.BLACK);
}
beginwite = beginwite + 38;
graphicsPrice.drawString(CommonUtil.getDateString(currentDate, "M.d"), beginwite, 10);
graphicsPrice.drawString("周" + CommonUtil.getChineseDayOfWeek(currentDate), beginwite, 25);
currentDate = (Date) DateUtil.getDate(currentDate, 1);
}
for (int g = 3; g < days; g++) {
if(currentDate.getTime()==dailyauditstatus.getNight().getTime()){
graphicsPrice.setColor(Color.gray);
}else{
graphicsPrice.setColor(Color.BLACK);
}
beginwite = beginwite + 38;
graphicsPrice.drawString(CommonUtil.getDateString(currentDate, "M.d"), beginwite, 10);
graphicsPrice.drawString("周" + CommonUtil.getChineseDayOfWeek(currentDate), beginwite, 25);
currentDate = (Date) DateUtil.getDate(currentDate, 1);
}
}
graphicsPrice.setFont(fontHead);
graphicsPrice.drawString("已离店",640, 20);
graphicsPrice.drawString("备注/确认号", 700, 20);
Font fontContent = new Font("宋体", Font.PLAIN, 14);// 内容字
graphicsPrice.setFont(fontContent);
int noY = 25;// 当前开始写的y坐标
Date startdate = (Date) DateUtil.getDate(dailyauditstatus.getNight(), -2);
Date currentDate = startdate;
int days = 6;
Orderitem orderitem=null,orderitemLast=null,orderitemNext=null;
beginwite = 380;
int beginId = 0;
int start=0;
int end=1;
boolean flat = false;
for (int i = 0; i < orderitemList.size(); i++) {
noY = noY + linHieght;
orderitem = (Orderitem) orderitemList.get(i);
Integer orderitemsize = 0;
orderitemsize = (Integer) orderitemsizeMap.get(orderitem.getOrderid());
if(i>0){
orderitemLast=(Orderitem)orderitemList.get(i-1);
}
if(i<orderitemList.size()-1){
orderitemNext=(Orderitem)orderitemList.get(i+1);
}
if(null==orderitemLast ){
start=1;
//System.out.println("pricebeanitemLast==NULL start:"+start);
}else if((int)orderitemLast.getOrderid()==(int)orderitem.getOrderid()){
start=8;
//System.out.println("pricebeanitemLast.getPricebeanid()==pricebeanitem.getPricebeanid() start:"+start);
}else if((int)orderitemLast.getOrderid()!=(int)orderitem.getOrderid()){
start=1;
//System.out.println("pricebeanitemLast.getPricebeanid():"+pricebeanitemLast.getPricebeanid()+",,"+pricebeanitem.getPricebeanid());
//System.out.println("pricebeanitemLast.getPricebeanid()!=pricebeanitem.getPricebeanid() start:"+start);
}
String roomtypenameratetype=orderitem.getRoomtypenameratetype()+" "+orderitem.getRoomqty()+"间";
if(null!=orderitemLast && orderitem.getRoomtypenameratetype().equals(orderitemLast.getRoomtypenameratetype())&& start!=1){
roomtypenameratetype="";
}
if (beginId != orderitem.getOrderid()) {
flat = true;
} else {
flat = false;
}
beginId = orderitem.getOrderid();
String pricingtype="";
if(orderitem.getPricingtype().intValue()==11){
pricingtype="现付";
}else{
pricingtype="挂帐";
}
if (null != orderitemsize) {
if (flat) {
graphicsPrice.setColor(Color.gray);
graphicsPrice.drawLine(15,noY-20 , 800, noY-20);//画线
graphicsPrice.setColor(Color.BLACK);
if (orderitemsize == 1) {
graphicsPrice.drawString(CommonUtil.getDefault(orderitem.getOrdercd()), 20, noY);
graphicsPrice.drawString(pricingtype, 40, noY+13);
} else {
graphicsPrice.drawString(CommonUtil.getDefault(orderitem.getOrdercd()), 20, noY + ((orderitemsize * 10) / 2));
graphicsPrice.drawString(pricingtype, 40, noY + ((orderitemsize * 10) / 2)+20);
}
}
}
graphicsPrice.drawString(roomtypenameratetype, 115, noY);
graphicsPrice.drawString(CommonUtil.getDateString(orderitem.getCheckinday(), "M.d")+"-"+CommonUtil.getDateString(orderitem.getCheckoutday(), "M.d")+" "+orderitem.getDays()+"晚", 200, noY);
graphicsPrice.drawString(CommonUtil.getDefault(orderitem.getRoomno()), 310, noY);
graphicsPrice.drawString(CommonUtil.getDefault(orderitem.getCheckinperson()), 350, noY);
currentDate = startdate;
Date checkoutday = DateUtil.getDate(orderitem.getCheckoutday(), -1);
for (int h = 0; h < days; h++) {
beginwite = beginwite + 38;
if (DateUtil.between(currentDate, orderitem.getCheckinday(), checkoutday)) {
Integer checkinstatus = (Integer) orderitemidDateStatusMap.get(CommonUtil.getDateString(currentDate, "yyyy-MM-dd") + orderitem.getOrderitemid());
if (null == checkinstatus || checkinstatus == 0) {
if(DateUtil.compare(currentDate,dailyauditstatus.getNight())==0){
graphicsPrice.drawString(CommonUtil.getDefault("□"), beginwite + 3, noY);
}else{
graphicsPrice.drawString(CommonUtil.getDefault("-"), beginwite + 3, noY);
}
} else if (checkinstatus == 1) {
graphicsPrice.drawString(CommonUtil.getDefault("√"), beginwite + 3, noY);
} else if (checkinstatus == 8) {
graphicsPrice.drawString(CommonUtil.getDefault("×"), beginwite + 3, noY);
}
}
currentDate = (Date) DateUtil.getDate(currentDate, 1);
}
graphicsPrice.drawString("□",beginwite + 40, noY);
beginwite = 380;
if (flat) {
order=orderDao.retrieveOrder(orderitem.getOrderid());
graphicsPrice.drawString(CommonUtil.getDefault(order.getConfirmno()), 700, noY);
}
}
graphicsPrice.drawLine(15, 35+( orderitemList.size() * 25), 800, 35+( orderitemList.size() * 25));//画线
return image;
}
public static BufferedImage createImageDayPriceNew(List orderitemList, Map orderitemsizeMap, Map orderitemidDateStatusMap, Dailyauditstatus dailyauditstatus) {
int imageHeight = 25+25+orderitemList.size()*25;
OrderDao orderDao=(OrderDao)Framework.getDaoFactory().getBean("orderDao");
Order order=null;
BufferedImage image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
Graphics graphicsPrice = image.getGraphics();
Font fontHead = new Font("宋体", Font.BOLD, 14);// 头部字
graphicsPrice.setFont(fontHead);
graphicsPrice.setColor(Color.WHITE);
graphicsPrice.fillRect(0, 0, imageWidth, imageHeight);
graphicsPrice.setColor(Color.BLACK);
graphicsPrice.drawString("酒店名称", 45, 15);
graphicsPrice.drawString("客人姓名", 150, 15);
graphicsPrice.drawString("入住/退房", 242, 15);
graphicsPrice.drawString("退房日期", 310, 15);
graphicsPrice.drawString("核对日期", 380, 15);
graphicsPrice.drawString("间数", 460, 15);
graphicsPrice.drawString("是否续住", 520, 15);
graphicsPrice.drawString("房号", 480, 15);
graphicsPrice.drawString("确认号", 710, 15);
graphicsPrice.drawLine(50, 15+5, 200, 15+5);//最后横线 换行150
graphicsPrice.setFont(new Font("楷体", Font.PLAIN, 13));
graphicsPrice.setFont(fontHead);
Font fontContent = new Font("宋体", Font.PLAIN, 14);// 内容字
graphicsPrice.setFont(fontContent);
int noY = 25;// 当前开始写的y坐标
graphicsPrice.drawLine(310, 15+5, 370, 15+5);//最后横线 换行150
//50 4个字
//画坚线
//分行120
graphicsPrice.drawLine(42, 0, 42, noY);//第一条竖线
//画横线
graphicsPrice.drawLine(42, 0, 760, 0);//第一条横线
graphicsPrice.drawLine(42, noY, 760, noY);//最后一条横线
return image;
}
public static List getTiffStreamByFileName(String fileName){
List result = new ArrayList();
if(null != fileName && fileName.length()>0){
String tiffName = fileName.substring(0,fileName.indexOf("."))+".tif";
try{
/*
OutputStream os = new FileOutputStream(tiffName);
TIFFEncodeParam param =new TIFFEncodeParam();
ImageEncoder enc = ImageCodec.createImageEncoder("TIFF", os,param);
enc.encode(src);
os.close();
*/
String fileNames= fileName.substring(fileName.lastIndexOf(File.separator)+1,fileName.length());
String tiffNames = tiffName.substring(tiffName