소스 검색

字段调整,生成二维码

wanfa99 2 년 전
부모
커밋
95a73bc667

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

@@ -6,6 +6,7 @@ import org.jeecg.modules.openApi.service.ISenYuDataSourceOne;
 import org.jeecg.modules.openApi.service.ISenYuDataSourceThree;
 import org.jeecg.modules.openApi.service.ISenYuDataSourceTwo;
 import org.jeecg.modules.system.util.JsonChangeUtils;
+import org.jeecg.modules.system.util.oConvertUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -26,9 +27,12 @@ public class Rdrecord11ServiceImpl  implements IRdrecord11Service {
     public JSONObject getRdrecord(String org, String cCode) throws Exception{
         JSONObject resultJson=new JSONObject();
         //主表查询SQl
-        String hsql="select *  From rdrecord11 where cCode='"+cCode+"'";
-        //子表查询SQl
-        String bsql="select a.* From rdrecords11 a,rdrecord11 b where  a.id=b.id and b.cCode='"+cCode+"'";
+        String hsql="select top 1  a.ccode,c.cVenName,a.cMPoCode,a.dDate,b.cDefine22,d.cWhName " +
+                "From  rdrecord11 a  left join rdrecords11 b on a.id=b.id left join  Vendor c on a.cVenCode=c.cVenCode " +
+                "left join Warehouse d on a.cWhCode=d.cWhCode where a.cCode='"+cCode+"'";
+        //子表查询SQl 件数/KG不确认
+        String bsql="select b.cbatch,b.cbatchproperty9,b.iquantity,b.cfree5,b.cinvcode,b.cfree4,b.cfree1,b.cfree6  " +
+                "From  rdrecord11 a   join rdrecords11 b on a.id=b.id where a.cCode='"+cCode+"'";
         if(org.equals("101")){
             List<Map<String, Object>> hresult = senYuDataSourceOne.queryForList(hsql);
             List<Map<String, Object>> bresult = senYuDataSourceOne.queryForList(bsql);
@@ -62,6 +66,7 @@ public class Rdrecord11ServiceImpl  implements IRdrecord11Service {
                 throw  new Exception(cCode+"单号查询有误,请确认数据!");
             }
             resultJson.put("b",JsonChangeUtils.toJSONObject(result));
+            oConvertUtils.generateQRCodeImage(JsonChangeUtils.toJSONObject(result).toString(),350,350,"C:/Users/AF/Desktop/text.png");
         }else if(org.equals("102")){
 
         }else if(org.equals("103")){

+ 28 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/util/oConvertUtils.java

@@ -1,13 +1,21 @@
 package org.jeecg.modules.system.util;
 
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.WriterException;
+import com.google.zxing.client.j2se.MatrixToImageWriter;
+import com.google.zxing.common.BitMatrix;
+import com.google.zxing.qrcode.QRCodeWriter;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.modules.system.entity.SysUser;
 
 import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.net.*;
+import java.nio.file.FileSystems;
+import java.nio.file.Path;
 import java.sql.Date;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -580,7 +588,6 @@ public class oConvertUtils {
 
 	}
     /**
-
      * 字符串+1方法,该方法将其结尾的整数+1,适用于任何以整数结尾的字符串,不限格式,不限分隔符。
      * @author 隔壁老赵
      * @param testStr 要+1的字符串
@@ -631,4 +638,24 @@ public class oConvertUtils {
         }
         return b.toString();
     }
+
+    /***
+     * 字段信息生成二维码图片
+     * @param text
+     * @param width
+     * @param height
+     * @param filePath
+     * @throws WriterException
+     * @throws IOException
+     */
+    public static void generateQRCodeImage(String text, int width, int height, String filePath) throws WriterException, IOException {
+        QRCodeWriter qrCodeWriter = new QRCodeWriter();
+
+        BitMatrix bitMatrix = qrCodeWriter.encode(text, BarcodeFormat.QR_CODE, width, height);
+
+        Path path = FileSystems.getDefault().getPath(filePath);
+
+        MatrixToImageWriter.writeToPath(bitMatrix, "PNG", path);
+
+    }
 }

+ 11 - 0
pom.xml

@@ -291,6 +291,17 @@
 					</exclusion>
 				</exclusions>
 			</dependency>
+            <!-- 二维码工具类 -->
+            <dependency>
+                <groupId>com.google.zxing</groupId>
+                <artifactId>core</artifactId>
+                <version>3.2.0</version>
+            </dependency>
+            <dependency>
+                <groupId>com.google.zxing</groupId>
+                <artifactId>javase</artifactId>
+                <version>3.2.0</version>
+            </dependency>
 		</dependencies>
 	</dependencyManagement>