Forráskód Böngészése

出库单打印参数调整

wanfa99 2 éve
szülő
commit
05e2e49f5b

+ 48 - 16
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/service/impl/Rdrecord11ServiceImpl.java

@@ -3,6 +3,8 @@ package org.jeecg.modules.openApi.service.impl;
 import com.alibaba.fastjson.JSONObject;
 import org.jeecg.modules.openApi.service.IRdrecord11Service;
 import org.jeecg.modules.openApi.service.ISenYuDataSourceThree;
+import org.jeecg.modules.system.entity.SysDictItem;
+import org.jeecg.modules.system.mapper.SysDictItemMapper;
 import org.jeecg.modules.system.util.JsonChangeUtils;
 import org.jeecg.modules.system.util.oConvertUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,9 +23,13 @@ import java.util.Map;
 @Service
 public class Rdrecord11ServiceImpl  implements IRdrecord11Service {
 
+
     @Autowired
     private ISenYuDataSourceThree senYuDataSourceThree;
 
+    @Autowired
+    private SysDictItemMapper sysDictItemMapper;
+
     @Override
     public JSONObject getRdrecord(String org, String cCode) throws Exception{
         JSONObject resultJson=new JSONObject();
@@ -52,6 +58,33 @@ public class Rdrecord11ServiceImpl  implements IRdrecord11Service {
     public JSONObject getRdrecordToPrint(String org, String cCode) throws Exception {
         JSONObject resultJson=new JSONObject();
 
+        //获取字典里打印参数
+        SysDictItem sysDictItemBySplit=null;
+        SysDictItem sysDictItemByPrint=null;
+        List<SysDictItem> listSysDictItem=sysDictItemMapper.selectItemsByMaincode("pda_setting");
+        for (SysDictItem item:listSysDictItem){
+            if(item.getItemText().equals("print_split_sum")){
+                sysDictItemBySplit=item;
+            }else if(item.getItemText().equals("print_imageParam")){
+                sysDictItemByPrint=item;
+            }
+        }
+        if(null==sysDictItemBySplit||null==sysDictItemByPrint){
+           throw new Exception("获取打印参数失败,请检查字典配置-PDA设置!");
+        }
+        int splitNum=Integer.parseInt(sysDictItemBySplit.getItemValue());//分割数量
+        String[] printParam=sysDictItemByPrint.getItemValue().split(",");
+        int backImageWidth=Integer.parseInt(printParam[0]);
+        int backImageHeight=Integer.parseInt(printParam[1]);
+        int qrWidth=Integer.parseInt(printParam[2]);
+        int qrHeight=Integer.parseInt(printParam[3]);
+        int x_text=Integer.parseInt(printParam[4]);
+        int y_text=Integer.parseInt(printParam[5]);
+        int x_image=Integer.parseInt(printParam[6]);
+        int spacing=Integer.parseInt(printParam[7]);
+        int fintSize=Integer.parseInt(printParam[8]);
+
+
         FileSystemView fsv = FileSystemView.getFileSystemView();
         File com = fsv.getHomeDirectory(); //这两行行是获取桌面路径的具体方法
         String finalPath=com.getPath()+"/imagePrint";//数据缓存位置,默认放在桌面
@@ -81,7 +114,7 @@ public class Rdrecord11ServiceImpl  implements IRdrecord11Service {
             for(int i=0;i<pljf.size();i++){
                 JSONObject onejson=pljf.get(i);
                 //生成二维码数量=
-                int num=(onejson.getBigDecimal("数量").divide(new BigDecimal("15000"),0,BigDecimal.ROUND_UP)).intValue();
+                int num=(onejson.getBigDecimal("数量").divide(new BigDecimal(splitNum),0,BigDecimal.ROUND_UP)).intValue();
                 sum=sum+num;
                 for(int j=0;j<num;j++){
                     serialNum=serialNum+1;
@@ -89,35 +122,34 @@ public class Rdrecord11ServiceImpl  implements IRdrecord11Service {
                     String newFilePath=finalPath+"/"+serialNum+".png";
                     pathList.add(newFilePath);
                     //生成二维码图片
-                    BufferedImage bufferedImage=oConvertUtils.getBufferedImage(onejson.toJSONString(),200,200);
+                    BufferedImage bufferedImage=oConvertUtils.getBufferedImage(onejson.toJSONString(),qrWidth,qrHeight);
                     //背景图片
-                    BufferedImage backImage = new BufferedImage(400, 400,BufferedImage.TYPE_INT_RGB);
+                    BufferedImage backImage = new BufferedImage(backImageWidth, backImageHeight,BufferedImage.TYPE_INT_RGB);
                     //显示文字 缸号,委外订单号,匹数,物料,描述,关键属性,供应商,接收方
 
                     //绘制合成
                     Graphics2D backGraphics=backImage.createGraphics();
-                    backGraphics.setClip(0, 0, 400, 400);//设置绘画的区域,默认背景是黑色,也叫做获取画笔,指定画笔可画的范围
+                    backGraphics.setClip(0, 0, backImageWidth, backImageHeight);//设置绘画的区域,默认背景是黑色,也叫做获取画笔,指定画笔可画的范围
                     backGraphics.setColor(Color.white);//设置画笔颜色
-                    backGraphics.fillRect(0, 0, 400, 400);//画一个矩形块,颜色是白色,因为画笔颜色是白色
+                    backGraphics.fillRect(0, 0, backImageWidth, backImageHeight);//画一个矩形块,颜色是白色,因为画笔颜色是白色
 
                     //放文字
                     backGraphics.setColor(Color.black);
-                    int bTextSize=15;
-                    Font font=new Font("宋体",Font.BOLD,bTextSize);
+                    Font font=new Font("宋体",Font.BOLD,fintSize);
                     backGraphics.setFont(font);
                     backGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
 
-                    backGraphics.drawString("缸号:"+onejson.getString("缸单条码"),0,30+bTextSize*0);
-                    backGraphics.drawString("委外订单号:"+onejson.getString("下游订单"),0,30+(bTextSize+5)*1);
-                    backGraphics.drawString("匹数:"+onejson.getString("匹数"),0,30+(bTextSize+5)*2);
-                    backGraphics.drawString("物料:"+onejson.getString("物料"),0,30+(bTextSize+5)*3);
-                    backGraphics.drawString("描述:"+onejson.getString("描述"),0,30+(bTextSize+5)*4);
-                    backGraphics.drawString("关键属性:",0,30+(bTextSize+5)*5);
-                    backGraphics.drawString("供应商:"+onejson.getString("供应商"),0,30+(bTextSize+5)*6);
-                    backGraphics.drawString("接收方:"+onejson.getString("接收方"),0,30+(bTextSize+5)*7);
+                    backGraphics.drawString("缸号:"+onejson.getString("缸单条码"),x_text,y_text+fintSize*0);
+                    backGraphics.drawString("委外订单号:"+onejson.getString("下游订单"),x_text,y_text+(spacing+fintSize)*1);
+                    backGraphics.drawString("匹数:"+onejson.getString("匹数"),x_text,y_text+(spacing+fintSize)*2);
+                    backGraphics.drawString("物料:"+onejson.getString("物料"),x_text,y_text+(spacing+fintSize)*3);
+                    backGraphics.drawString("描述:"+onejson.getString("描述"),x_text,y_text+(spacing+fintSize)*4);
+                    backGraphics.drawString("关键属性:",x_text,y_text+(spacing+fintSize)*5);
+                    backGraphics.drawString("供应商:"+onejson.getString("供应商"),x_text,y_text+(spacing+fintSize)*6);
+                    backGraphics.drawString("接收方:"+onejson.getString("接收方"),x_text,y_text+(spacing+fintSize)*7);
 
                     //放图片
-                    backGraphics.drawImage(bufferedImage, 0,180, bufferedImage.getWidth(), bufferedImage.getHeight(),null);
+                    backGraphics.drawImage(bufferedImage, x_image,y_text+spacing+(spacing+fintSize)*7, bufferedImage.getWidth(), bufferedImage.getHeight(),null);
 
                     backGraphics.dispose();// 释放对象
 

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/SysDictItemMapper.java

@@ -17,4 +17,7 @@ import java.util.List;
 public interface SysDictItemMapper extends BaseMapper<SysDictItem> {
     @Select("SELECT * FROM sys_dict_item WHERE DICT_ID = #{mainId} order by sort_order asc, item_value asc")
     public List<SysDictItem> selectItemsByMainId(String mainId);
+
+    @Select("select*From sys_dict_item where dict_id=(select id From sys_dict where dict_code=#{mainCode})")
+    public List<SysDictItem> selectItemsByMaincode(String mainCode);
 }