Commit eb06b89d by 胡懿

修改查询二维码的分页代码

parent ef912b0b
...@@ -30,6 +30,7 @@ public class GoodsInfo extends DataEntity<GoodsInfo> { ...@@ -30,6 +30,7 @@ public class GoodsInfo extends DataEntity<GoodsInfo> {
private BigDecimal amount; // 单价 private BigDecimal amount; // 单价
private List<QrCode> qrCodeList; // 二维码集合(xml中无关联查询) private List<QrCode> qrCodeList; // 二维码集合(xml中无关联查询)
private List<String> modelList; // 查询时使用的属性
public GoodsInfo() { public GoodsInfo() {
super(); super();
...@@ -111,4 +112,11 @@ public class GoodsInfo extends DataEntity<GoodsInfo> { ...@@ -111,4 +112,11 @@ public class GoodsInfo extends DataEntity<GoodsInfo> {
this.qrCodeList = qrCodeList; this.qrCodeList = qrCodeList;
} }
public List<String> getModelList() {
return modelList;
}
public void setModelList(List<String> modelList) {
this.modelList = modelList;
}
} }
\ No newline at end of file
package com.jeeplus.modules.warehouse.ikanalyzer; package com.jeeplus.modules.warehouse.ikanalyzer;
import java.io.StringReader; import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import org.wltea.analyzer.cfg.DefaultConfig; import org.wltea.analyzer.cfg.DefaultConfig;
import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme; import org.wltea.analyzer.core.Lexeme;
import org.wltea.analyzer.cfg.Configuration; import org.wltea.analyzer.cfg.Configuration;
public class IKSegmenterTest { public class IKSegmenter {
private static Configuration m_wordCut_cfg; private static Configuration m_wordCut_cfg;
...@@ -16,7 +17,7 @@ public class IKSegmenterTest { ...@@ -16,7 +17,7 @@ public class IKSegmenterTest {
// 参数2为是否使用智能分词 // 参数2为是否使用智能分词
// true:使用智能分词 // true:使用智能分词
// false:使用最细粒度分词 // false:使用最细粒度分词
IKSegmenter ikSegmenter = new IKSegmenter(sr, useSmart); org.wltea.analyzer.core.IKSegmenter ikSegmenter = new org.wltea.analyzer.core.IKSegmenter(sr, useSmart);
Lexeme word = null; Lexeme word = null;
String w = null; String w = null;
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
...@@ -38,16 +39,21 @@ public class IKSegmenterTest { ...@@ -38,16 +39,21 @@ public class IKSegmenterTest {
* @param b ture为智能拆分,false为最细粒度拆分 * @param b ture为智能拆分,false为最细粒度拆分
* @return * @return
*/ */
public static String splitStr(String text, boolean b) { public static List<String> splitStr(String text, boolean b) {
String strs = text; String strs = text;
m_wordCut_cfg = DefaultConfig.getInstance(); m_wordCut_cfg = DefaultConfig.getInstance();
try { try {
IKSegmenterTest ikSegmenterTest = new IKSegmenterTest(); IKSegmenter ikSegmenterTest = new IKSegmenter();
strs = ikSegmenterTest.parse(text,b); strs = ikSegmenterTest.parse(text,b);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return strs; List<String> list = new ArrayList<>();
String [] strArr = strs.split("|");
for (String str : strArr) {
list.add(str);
}
return list;
} }
public static void main(String[] args) { public static void main(String[] args) {
String text = "185的绿军鞋15双"; String text = "185的绿军鞋15双";
......
...@@ -8,6 +8,8 @@ import com.jeeplus.core.persistence.DataEntity; ...@@ -8,6 +8,8 @@ import com.jeeplus.core.persistence.DataEntity;
import com.jeeplus.common.utils.excel.annotation.ExcelField; import com.jeeplus.common.utils.excel.annotation.ExcelField;
import com.jeeplus.modules.warehouse.goods.entity.GoodsInfo; import com.jeeplus.modules.warehouse.goods.entity.GoodsInfo;
import java.util.List;
/** /**
* 二维码Entity * 二维码Entity
* @author 胡懿 * @author 胡懿
...@@ -63,4 +65,5 @@ public class QrCode extends DataEntity<QrCode> { ...@@ -63,4 +65,5 @@ public class QrCode extends DataEntity<QrCode> {
public void setState(String state) { public void setState(String state) {
this.state = state; this.state = state;
} }
} }
\ No newline at end of file
...@@ -175,6 +175,7 @@ ...@@ -175,6 +175,7 @@
FROM t_wh_qr a FROM t_wh_qr a
LEFT JOIN t_wh_goods_info gi ON a.goods_info_id = gi.id LEFT JOIN t_wh_goods_info gi ON a.goods_info_id = gi.id
LEFT JOIN t_wh_material_type type ON type.id = gi.type_id LEFT JOIN t_wh_material_type type ON type.id = gi.type_id
LEFT JOIN t_wh_goods g ON g.id = gi.goods_id
<where> <where>
a.del_flag = #{DEL_FLAG_NORMAL} a.del_flag = #{DEL_FLAG_NORMAL}
<if test="goodsInfo.goods.batchNum != null and goodsInfo.goods.batchNum != ''"> <if test="goodsInfo.goods.batchNum != null and goodsInfo.goods.batchNum != ''">
...@@ -184,7 +185,7 @@ ...@@ -184,7 +185,7 @@
AND gi.type_id = #{goodsInfo.type.id} AND gi.type_id = #{goodsInfo.type.id}
</if> </if>
<if test="goodsInfo.model != null and goodsInfo.model != ''"> <if test="goodsInfo.model != null and goodsInfo.model != ''">
AND gi.type_id = #{goodsInfo.model} AND gi.model = #{goodsInfo.model}
</if> </if>
</where> </where>
<choose> <choose>
......
...@@ -238,8 +238,8 @@ public class DrawQrcodeUtil { ...@@ -238,8 +238,8 @@ public class DrawQrcodeUtil {
public static BufferedImage createAssetImageNew(File qrcodeFile,QrCode qrCode) throws IOException { public static BufferedImage createAssetImageNew(File qrcodeFile,QrCode qrCode) throws IOException {
GoodsInfo goodsInfo = qrCode.getGoodsInfo(); GoodsInfo goodsInfo = qrCode.getGoodsInfo();
QRcodeSize qRcodeSize = null; QRcodeSize qRcodeSize = null;
qRcodeSize = new QRcodeSize(8,50,330,78,50,50,300,300,new Color(34,25,21)); qRcodeSize = new QRcodeSize(8,200,1400,78,200,200,1200,1200,new Color(34,25,21));
BufferedImage bgImage = new BufferedImage(400, 600, BufferedImage.TYPE_4BYTE_ABGR); BufferedImage bgImage = new BufferedImage(1600, 2400, BufferedImage.TYPE_4BYTE_ABGR);
Graphics2D g2 = bgImage.createGraphics(); Graphics2D g2 = bgImage.createGraphics();
BufferedImage qrcodeImage = ImageIO.read(qrcodeFile); BufferedImage qrcodeImage = ImageIO.read(qrcodeFile);
...@@ -251,12 +251,12 @@ public class DrawQrcodeUtil { ...@@ -251,12 +251,12 @@ public class DrawQrcodeUtil {
, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); , RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
g2.setRenderingHints(rh); g2.setRenderingHints(rh);
Font font = new Font("黑体",Font.BOLD,3 * qRcodeSize.getInitfontSize()); Font font = new Font("黑体",Font.BOLD,16 * qRcodeSize.getInitfontSize());
g2.setFont(font); //设置字体:字体、字号、大小 g2.setFont(font); //设置字体:字体、字号、大小
g2.setColor(qRcodeSize.color);//设置背景颜色 g2.setColor(qRcodeSize.color);//设置背景颜色
// g2.setBackground(c); // g2.setBackground(c);
int contentX = qRcodeSize.getInitContentX(); int contentX = qRcodeSize.getInitContentX();
int contentY = qRcodeSize.getInitContentY() + 70; int contentY = qRcodeSize.getInitContentY() + 200;
//写二维码 //写二维码
g2.drawImage(qrcodeImage,qRcodeSize.getQrcodeX(),qRcodeSize.getQrcodeY(),qRcodeSize.getQrcodeWidth(),qRcodeSize.getQrcodeHeight(),null,null); g2.drawImage(qrcodeImage,qRcodeSize.getQrcodeX(),qRcodeSize.getQrcodeY(),qRcodeSize.getQrcodeWidth(),qRcodeSize.getQrcodeHeight(),null,null);
...@@ -272,21 +272,32 @@ public class DrawQrcodeUtil { ...@@ -272,21 +272,32 @@ public class DrawQrcodeUtil {
//写入货品类型 //写入货品类型
String contentTitle2 = "货品类型:"; String contentTitle2 = "货品类型:";
int contentTitle2Width = g2.getFontMetrics().stringWidth(contentTitle2); int contentTitle2Width = g2.getFontMetrics().stringWidth(contentTitle2);
g2.drawString(contentTitle2,contentX,contentY+50); g2.drawString(contentTitle2,contentX,contentY+200);
String typeName = formatContent(goodsInfo.getType().getName(),10); String typeName = formatContent(goodsInfo.getType().getName(),10);
as = new AttributedString(typeName); as = new AttributedString(typeName);
as.addAttribute(TextAttribute.FONT, font); as.addAttribute(TextAttribute.FONT, font);
as.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_LOW_DASHED, 0, typeName.length()); as.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_LOW_DASHED, 0, typeName.length());
g2.drawString(as.getIterator(),contentX+contentTitle2Width,contentY+50); g2.drawString(as.getIterator(),contentX+contentTitle2Width,contentY+200);
//写入物资编码 //写入物资编码
String contentTitle4 = "物资编码:"; String contentTitle4 = "物资编码:";
int contentTitle4Width = g2.getFontMetrics().stringWidth(contentTitle4); int contentTitle4Width = g2.getFontMetrics().stringWidth(contentTitle4);
g2.drawString(contentTitle4,contentX,contentY+100); g2.drawString(contentTitle4,contentX,contentY+400);
String code = formatContent(qrCode.getCode(),10); String code = qrCode.getCode();
as = new AttributedString(code); if (code.length() > 10) {
String str1 = code.substring(0, 9);
str1 = formatContent(str1,10);
as = new AttributedString(str1);
as.addAttribute(TextAttribute.FONT, font); as.addAttribute(TextAttribute.FONT, font);
as.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_LOW_DASHED, 0, code.length()); as.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_LOW_DASHED, 0, str1.length());
g2.drawString(as.getIterator(),contentX+contentTitle4Width,contentY+100); g2.drawString(as.getIterator(),contentX+contentTitle4Width,contentY+400);
String str2 = code.substring(9, code.length());
str2 = formatContent(str2,10);
as = new AttributedString(str2);
as.addAttribute(TextAttribute.FONT, font);
as.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_LOW_DASHED, 0, str2.length());
g2.drawString(as.getIterator(),contentX+contentTitle4Width,contentY+600);
}
return bgImage; return bgImage;
} }
......
...@@ -10,6 +10,7 @@ import com.jeeplus.modules.warehouse.goods.entity.Goods; ...@@ -10,6 +10,7 @@ import com.jeeplus.modules.warehouse.goods.entity.Goods;
import com.jeeplus.modules.warehouse.goods.entity.GoodsInfo; import com.jeeplus.modules.warehouse.goods.entity.GoodsInfo;
import com.jeeplus.modules.warehouse.goods.mapper.GoodsInfoMapper; import com.jeeplus.modules.warehouse.goods.mapper.GoodsInfoMapper;
import com.jeeplus.modules.warehouse.goods.mapper.GoodsMapper; import com.jeeplus.modules.warehouse.goods.mapper.GoodsMapper;
import com.jeeplus.modules.warehouse.ikanalyzer.IKSegmenter;
import com.jeeplus.modules.warehouse.ledger.dto.CountLedgerInfo; import com.jeeplus.modules.warehouse.ledger.dto.CountLedgerInfo;
import com.jeeplus.modules.warehouse.qrcode.entity.QrCode; import com.jeeplus.modules.warehouse.qrcode.entity.QrCode;
import com.jeeplus.modules.warehouse.qrcode.mapper.QrCodeMapper; import com.jeeplus.modules.warehouse.qrcode.mapper.QrCodeMapper;
...@@ -221,6 +222,10 @@ public class StorageService extends CrudService<StorageMapper, Storage> { ...@@ -221,6 +222,10 @@ public class StorageService extends CrudService<StorageMapper, Storage> {
@Transactional(readOnly = false) @Transactional(readOnly = false)
public Page<StorageInfo> findByPcTypeModel(Page<StorageInfo> page, GoodsInfo goodsInfo) { public Page<StorageInfo> findByPcTypeModel(Page<StorageInfo> page, GoodsInfo goodsInfo) {
QrCode temQr = new QrCode(); QrCode temQr = new QrCode();
String model = goodsInfo.getModel();
if (StringUtils.isNotBlank(model)) {
goodsInfo.setModelList(IKSegmenter.splitStr(model, false));
}
temQr.setGoodsInfo(goodsInfo); temQr.setGoodsInfo(goodsInfo);
List<QrCode> qrCodeList = qrCodeMapper.findByPcTypeModel(temQr); List<QrCode> qrCodeList = qrCodeMapper.findByPcTypeModel(temQr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment