1.修复看板问题

master
董哲奇 3 months ago
parent d3b27f4f68
commit 0ed582cc8f

@ -282,6 +282,17 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.4.1</version>
</dependency>
</dependencies>
<build>

@ -1,32 +1,143 @@
package com.dsic.gj_erp;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.date.TimeInterval;
import cn.hutool.extra.qrcode.QrCodeUtil;
import cn.hutool.extra.qrcode.QrConfig;
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.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageContentStream;
import org.apache.pdfbox.pdmodel.PDPageTree;
import org.apache.pdfbox.pdmodel.graphics.image.JPEGFactory;
import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
import org.apache.pdfbox.text.PDFTextStripper;
import org.apache.pdfbox.text.PDFTextStripperByArea;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class Test {
public static void main(String[] args) throws IOException {
System.out.println(DateUtil.thisYear());
// System.out.println(DateUtil.thisYear());
// System.out.println(StrUtil.padPre("1",3,"0"));
//String aaa="gagagag";
//System.out.println(aaa.split("@")[0]);
//System.out.println("aaa = " + String.format("%03d",1));
// MatrixToImageWriter.
// String pdfFilePath = "E:/B046HC103HN第046批量数控套料图2023-05-11.pdf"; // PDF文件路径
// PDDocument document = PDDocument.load(new File(pdfFilePath));
TimeInterval timer = DateUtil.timer();
String pdfFilePath = "E:\\T300K-130_1_20250106\\PDF\\B001HC103HN数控套料图.pdf"; // PDF文件路径
PDDocument document = PDDocument.load(new File(pdfFilePath));
// PDFTextStripper stripper = new PDFTextStripper();
// String text = stripper.getText(document);
// document.close();
// String[] split = text.split("\\n");
// List<QrCodeDto> list = new ArrayList<>();
QrConfig config = new QrConfig(300, 300);//二维码宽/高
// 设置边距,既二维码和背景之间的边距(即白边大小)
config.setMargin(0);
// 设置前景色,既二维码颜色(青色)
//config.setForeColor(Color.CYAN.getRGB());
// 设置背景色(灰色)
//config.setBackColor(Color.GRAY.getRGB());
// for (int i = 0; i < split.length; i++) {
// String str = split[i];
// if (str.contains("船名 批量 图纸比例 套料图号 图号 页码")) {
// str = split[i - 4];
// QrCodeDto qrCodeDto = new QrCodeDto();
// try {
// qrCodeDto.page = Integer.parseInt(str.split(" ")[0]);
// }catch (Exception e){
// str = split[i - 3];
// qrCodeDto.page = Integer.parseInt(str.split(" ")[0]);
// }
//
// // 输出提取的文本到控制台
// list.add(qrCodeDto);
// }
// if (str.contains("序号 零件属性零件编号 零件属性 零件属性 零件属性序号 序号 序号零件编号 零件编号 零件编号")) {
// str = split[i + 1];
// if (!list.isEmpty()) {
// String[] split1 = str.split(" ");
// String dcch = split1[0];
// String dcpl = split1[1];
// String tzbh = split1[3];
// QrCodeDto qrCodeDto = list.get(list.size() - 1);
//// BitMatrix qrcode = createQrcode(String.format("%s_%s_%s", dcch, dcpl, tzbh));
//// assert qrcode != null;
// //qrCodeDto.bufferedImage = MatrixToImageWriter.toBufferedImage(qrcode);
// qrCodeDto.bufferedImage = QrCodeUtil.generate(String.format("%s_%s_%s", dcch, dcpl, tzbh), config);
////
// }
// }
// }
for (int pageNumber = 1; pageNumber < document.getNumberOfPages(); ++pageNumber) {
PDPage page = document.getPage(pageNumber);
String textByRegion = getTextByRegion(page, 80, 50, 1100, 40);
// System.out.println(textByRegion);
String[] split = textByRegion.split(" ");
String dcch = split[1];
String dcpl = split[3];
String tzbh = split[7];
String pageIndex = split[12];
BufferedImage bufferedImage = QrCodeUtil.generate(String.format("%s_%s_%s", dcch, dcpl, tzbh), config);
PDPageContentStream contentStream = new PDPageContentStream(document, page, PDPageContentStream.AppendMode.APPEND, true, true);
PDImageXObject qrCodeImage = JPEGFactory.createFromImage(document, bufferedImage);
contentStream.drawImage(qrCodeImage, 10, 10, 75, 75); // 在PDF中的坐标位置添加二维码
contentStream.close();
}
document.save("E:/updated_document.pdf");
document.close();
System.out.println(timer.interval());
// 输出提取的文本到控制台
// System.out.println(text);
//
// // 可以选择将文本写入文件
// String outputPath = "E:/B046HC103HN第046批量数控套料图2023-05-11.txt"; // 输出文本文件路径
// Files.write(Paths.get(outputPath), text.getBytes());
// 可以选择将文本写入文件
//String outputPath = "E:/B001HC103HN数控套料图.txt"; // 输出文本文件路径
//Files.write(Paths.get(outputPath), text.getBytes());
}
private static BitMatrix createQrcode(String dataToEncode) {
QRCodeWriter qrCodeWriter = new QRCodeWriter();
int width = 200;
int height = 200;
BitMatrix bitMatrix = null;
try {
return qrCodeWriter.encode(dataToEncode, BarcodeFormat.QR_CODE, width, height);
} catch (WriterException e) {
e.printStackTrace();
}
return null;
}
private static String getTextByRegion(PDPage page,double x,double y,double width,double height) throws IOException {
PDFTextStripperByArea stripper = new PDFTextStripperByArea();
stripper.setSortByPosition(true);
stripper.addRegion("textRegion", new Rectangle2D.Double(x, y, width, height)); // 假设二维码区域是100x100从(100,100)开始
stripper.extractRegions(page);
return stripper.getTextForRegion("textRegion"); // 获取二维码区域的文本
}
static class QrCodeDto {
public int page;
public BufferedImage bufferedImage;
}
}

@ -14,7 +14,7 @@ public interface KbanMapper {
List<Map<String, Object>> getProjects();
//线表重量
List<Double> getEveryMonXbzlByNf(String nf);
List<Double> getEveryMonXbzlByNf(String nf,Integer version);
//作业计划完成重量
List<Map<String,Object>> getEveryCompZlByNf(String from, String to);
@ -48,7 +48,7 @@ public interface KbanMapper {
Map<String, Object> todayZyjhzx(String from, String to);
List<Map<String, Object>> xbgtt(String nf);
List<Map<String, Object>> xbgtt(String nf,Integer version);
List<Map<String, Object>> zrcpcsl(String from, String to);

@ -1,14 +1,15 @@
package com.dsic.gj_erp.service;
import java.io.File;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import cn.hutool.core.io.FileUtil;
import com.dsic.gj_erp.bean.xiaochi.Device;
import com.dsic.gj_erp.mapper.xiaochi.DeviceMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.dsic.gj_erp.bean.jhgk.DmYdjh;
@ -19,12 +20,15 @@ import cn.hutool.core.date.DateUtil;
import lombok.AllArgsConstructor;
@Service
@AllArgsConstructor
@RequiredArgsConstructor
public class KbanService {
private final KbanMapper kbanMapper;
private final DeviceMapper deviceMapper;
@Value("${xbjh-path}")
String xbjhPath;
public List<Device> getDeviceStatus(){
return deviceMapper.getDeviceStatus();
}
@ -57,7 +61,8 @@ public class KbanService {
}
public List<Map<String, Object>> xbgtt(String nf){
return kbanMapper.xbgtt(nf);
return kbanMapper.xbgtt(nf,this.getMaxVersion());
}
public Map<String, Object> todayZyjhzx() {
@ -227,7 +232,8 @@ public class KbanService {
}
public List<Double> getEveryMonXbzlByNf(String nf) {
return kbanMapper.getEveryMonXbzlByNf(nf);
return kbanMapper.getEveryMonXbzlByNf(nf,this.getMaxVersion());
}
public List<Map<String,Object>> getEveryCompZlByNf(String nf) {
@ -236,4 +242,26 @@ public class KbanService {
return kbanMapper.getEveryCompZlByNf(from.toString("yyyy/MM/dd"), to.toString("yyyy/MM/dd"));
}
private Integer getMaxVersion(){
File[] files = FileUtil.ls(xbjhPath);
AtomicInteger maxVersion = new AtomicInteger(0);
if (files.length > 0) {
HashSet<String> names = new HashSet<>();
for (File file1 : files) {
String name = FileUtil.getPrefix(file1.getName());
if (name.contains(DateUtil.thisYear()+"")){
String[] s = name.split("_");
names.add(s[s.length - 1]);
}
}
names.stream()
.max(String::compareTo)
.ifPresent(item -> {
String v = item.replace("v", "");
maxVersion.set(Integer.parseInt(v));
});
}
return maxVersion.get();
}
}

@ -3,7 +3,7 @@
<mapper namespace="com.dsic.gj_erp.mapper.KbanMapper">
<select id="getEveryMonXbzlByNf" resultType="double">
select sum(zl) from dm_xbjh where nf=#{nf} group by yf
select sum(zl) from dm_xbjh where nf=#{nf} and version=#{version} group by yf
</select>
<select id="getEveryCompZlByNf" resultType="map">
@ -12,7 +12,9 @@
from
dm_ydjh
WHERE
jssj BETWEEN #{from} and #{to} group by MONTH(CAST(jssj AS DATE))
jssj BETWEEN #{from} and #{to} and lx='b' and zt>=11
group by
MONTH(CAST(jssj AS DATE))
order by
MONTH(CAST(jssj AS DATE))
</select>
@ -20,7 +22,7 @@
<select id="getEveryKw" resultType="java.util.Map">
SELECT
zt,SUBSTRING(tzbh,6,1) kw
from dm_ydjh WHERE zt>=11 and jssj BETWEEN #{from} and #{to}
from dm_ydjh WHERE zt>=11 and jssj BETWEEN #{from} and #{to} and lx='b'
</select>
<select id="getZjjhByUserCode" resultType="com.dsic.gj_erp.bean.jhgk.DmYdjh">
@ -30,7 +32,7 @@
dm_ydjh
WHERE
(slfkry =#{userCode} or pwfkry =#{userCode} or llfkry =#{userCode} or qgfkry =#{userCode} or hxfkry =#{userCode})
and jssj between #{from} and #{to}
and jssj between #{from} and #{to} and lx='b'
</select>
<select id="getSb" resultType="java.util.Map">
@ -39,7 +41,12 @@
case when zt>=42 then sum(1) end p,
case when zt>=52 then sum(1) end hx,
case when zt>=62 then sum(1) end qg
from dm_ydjh WHERE zt>=42 and (hxfkrq=#{day} or qgfkrq=#{day}) group by hxsb ,qgsb,zt
from
dm_ydjh
WHERE
zt>=42 and lx='b' and (hxfkrq=#{day} or qgfkrq=#{day})
group by
hxsb ,qgsb,zt
</select>
<select id="getZyjhDetailBySbCode" resultType="com.dsic.gj_erp.bean.jhgk.DmYdjh">
@ -48,7 +55,7 @@
from
dm_ydjh
<where>
zt>=42 and (hxsb=#{code} or qgsb=#{code})
zt>=42 and lx='b' and (hxsb=#{code} or qgsb=#{code})
</where>
</select>
@ -59,7 +66,7 @@
from
dm_ydjh
WHERE
jssj BETWEEN #{from} and #{to}
jssj BETWEEN #{from} and #{to} and lx='b'
group by
dc_ch ,dc_pl ,qgfkrq
order by dc_ch ,dc_pl
@ -70,13 +77,13 @@
DISTINCT dc_ch ,dc_pl ,
sum(case when zt>=2 then 1 else 0 end ) OVER(PARTITION by dc_ch,dc_pl) jhsl,
sum(case when zt>11 then 1 else 0 end ) OVER(PARTITION by dc_ch,dc_pl) 一区,
sum(case when zt>=62 and (SUBSTRING(tzbh,6,1)=1 or SUBSTRING(tzbh,6,1)=3) then 1 else 0 end ) OVER(PARTITION by dc_ch,dc_pl) 二区,
sum(case when zt>=62 and SUBSTRING(tzbh,6,1)=2 then 1 else 0 end ) OVER(PARTITION by dc_ch,dc_pl) 三区,
sum(case when zt>=62 and SUBSTRING(tzbh,6,1)=4 then 1 else 0 end ) OVER(PARTITION by dc_ch,dc_pl) 四区
sum(case when zt>=62 and zyq1='二区' then 1 else 0 end ) OVER(PARTITION by dc_ch,dc_pl) 二区,
sum(case when zt>=62 and zyq1='三区' then 1 else 0 end ) OVER(PARTITION by dc_ch,dc_pl) 三区,
sum(case when zt>=62 and zyq1='四区' then 1 else 0 end ) OVER(PARTITION by dc_ch,dc_pl) 四区
from
dm_ydjh
WHERE
zt>=2 and jssj BETWEEN #{from} and #{to}
zt>=2 and jssj BETWEEN #{from} and #{to} and lx='b'
<choose>
<when test="zyq==2">
and (SUBSTRING(tzbh,6,1)=1 or SUBSTRING(tzbh,6,1)=3)
@ -107,7 +114,7 @@
from
dm_ydjh
WHERE
slfkrq = #{today} or hxfkrq = #{today} or qgfkrq = #{today}
lx='b' and (slfkrq = #{today} or hxfkrq = #{today} or qgfkrq = #{today})
</select>
<select id="qfxq" resultType="java.lang.String">
@ -116,34 +123,29 @@
<select id="qfxqDetail" resultType="java.util.Map">
SELECT DISTINCT
SUM(isnull(b.bclqzl,0)/10000) over(PARTITION by dcch) zl,dcch dcCh
from dm_sygdxq a left join
(SELECT DISTINCT dcch,pl,tzbh,bclqzl from dm_bom ) b
on a.DC_CH =b.dcch and a.DC_PL =b.pl
where a.xzglxq BETWEEN #{from} and #{to} and isnull(dcch,'')!=''
SUM(isnull(bclqzl,0)/1000) over(PARTITION by dc_ch) as zl,dc_ch dcCh
from dm_sygd_mx
where jssj BETWEEN #{from} and #{to} and isnull(dc_ch,'')!=''
</select>
<select id="qfxqDetail1" resultType="java.util.Map">
SELECT
DISTINCT dc_ch dcCh,
sum(case when isnull(dc_pl,'')!='' then 1 else 0 end) OVER(PARTITION by dc_ch) pcsl
DISTINCT dc_ch dcCh,SUM(1) OVER(PARTITION by dc_ch) pcsl
from
dm_sygdxq
where
xzglxq BETWEEN #{from} and #{to}
(SELECT dc_ch from dm_sygd_mx where jssj BETWEEN #{from} and #{to} GROUP by dc_ch ,dc_pl) a
</select>
<select id="qfxqWcqk" resultType="java.util.Map">
SELECT * from (
SELECT
DISTINCT xq.dc_ch ,
sum(isnull(xq.dzjz,0)/1000) over(PARTITION by xq.dc_ch) xqzl ,
sum(isnull(xq.bclqzl,0)/1000) over(PARTITION by xq.dc_ch) xqzl ,
SUM(CONVERT( decimal, isnull(ydjh.bclqzl,'0')/1000)) over(PARTITION by xq.dc_ch) jhzl ,
SUM(CONVERT( decimal, case when ydjh.zt>=62 then ydjh.bclqzl else '0' end)) over(PARTITION by xq.dc_ch) wczl
from
dm_sygdxq xq left join dm_ydjh ydjh on xq.dc_ch =ydjh.dc_ch and xq.dc_pl =ydjh.dc_pl and xq.DC_FD =ydjh.DC_FD
dm_sygd_mx xq left join dm_ydjh ydjh on xq.dc_ch =ydjh.dc_ch and xq.dc_pl =ydjh.dc_pl and xq.tzbh =ydjh.tzbh
where
xq.xzglxq BETWEEN #{from} and #{to}
xq.jssj BETWEEN #{from} and #{to} and ydjh.lx='b'
) a where a.jhzl!=0
</select>
@ -154,7 +156,8 @@
sum(case when zt>11 then 1 else 0 end) sl
from
dm_ydjh
WHERE jssj BETWEEN #{from} and #{to}
WHERE
jssj BETWEEN #{from} and #{to} and lx='b'
</select>
<select id="zyjhzx" resultType="java.util.Map">
@ -162,34 +165,34 @@
DISTINCT zyq,day,count(1) over(PARTITION by zyq,day) sl
from (
SELECT
'一区' as zyq,tzbh,zt,slfkrq as day
'一区' as zyq,tzbh,zt,DATEPART(DD,slfkrq) as day
from
dm_ydjh
WHERE
zt >=21 and jssj BETWEEN #{from} and #{to}
zt >=21 and jssj BETWEEN #{from} and #{to} and lx='b'
UNION ALL
SELECT
'二区' as zyq,tzbh,zt,qgfkrq as day
'二区' as zyq,tzbh,zt,DATEPART(DD,qgfkrq) as day
from
dm_ydjh
WHERE
zt >=62 and jssj BETWEEN #{from} and #{to} and (SUBSTRING(tzbh,6,1)='1' or
SUBSTRING(tzbh,6,1)='3')
zt >=62 and jssj BETWEEN #{from} and #{to} and zyq1='二区' and lx='b'
UNION ALL
SELECT
'三区',tzbh,zt,qgfkrq as day
'三区',tzbh,zt,DATEPART(DD,qgfkrq) as day
from
dm_ydjh
WHERE
zt >=62 and jssj BETWEEN #{from} and #{to} and SUBSTRING(tzbh,6,1)='2'
zt >=62 and jssj BETWEEN #{from} and #{to} and zyq1='三区' and lx='b'
UNION ALL
SELECT
'四区',tzbh,zt,qgfkrq as day
'四区',tzbh,zt,DATEPART(DD,qgfkrq) as day
from
dm_ydjh
WHERE
zt >=62 and jssj BETWEEN #{from} and #{to} and SUBSTRING(tzbh,6,1)='4'
zt >=62 and jssj BETWEEN #{from} and #{to} and zyq1='四区' and lx='b'
) a
where isnull(a.day,'')!=''
</select>
<select id="todayZyjhzx" resultType="java.util.Map">
@ -200,7 +203,7 @@
from
dm_ydjh
WHERE
jssj BETWEEN #{from} and #{to}
jssj BETWEEN #{from} and #{to} and lx='b'
</select>
<select id="xbgtt" resultType="java.util.Map">
@ -208,7 +211,7 @@
DISTINCT a.dc_ch dcCh,a.yf,sum(a.zl/1000) over(PARTITION by a.dc_ch,a.yf) zl ,
sum(CONVERT(decimal,b.bclqzl)/1000) over(PARTITION by b.dc_ch,MONTH(CAST(b.jssj AS DATE))) jhzl
from dm_xbjh a left join dm_ydjh b on a.dc_ch =b.dc_ch and
CONVERT(int,a.yf)=MONTH(CAST(b.jssj AS DATE)) WHERE a.nf=#{nf}
CONVERT(int,a.yf)=MONTH(CAST(b.jssj AS DATE)) WHERE a.nf=#{nf} and a.version=#{version}
order by a.dc_ch, a.yf
</select>
@ -241,11 +244,9 @@
<select id="xqzl" resultType="BigDecimal">
SELECT
SUM(isnull(b.bclqzl,0)/10000)
from dm_sygdxq a left join
(SELECT DISTINCT dcch,pl,tzbh,bclqzl from dm_bom ) b
on a.DC_CH =b.dcch and a.DC_PL =b.pl
where a.xzglxq BETWEEN #{from} and #{to}
SUM(isnull(bclqzl,0)/1000)
from dm_sygd_mx
where jssj BETWEEN #{from} and #{to}
</select>
<select id="dhzl" resultType="BigDecimal">
@ -254,11 +255,15 @@
</select>
<select id="jhzl" resultType="BigDecimal">
SELECT SUM(isnull(bclqzl,0)/1000) FROM dm_ydjh WHERE jssj BETWEEN #{from} and #{to}
SELECT SUM(isnull(bclqzl,0)/1000) FROM dm_ydjh WHERE jssj BETWEEN #{from} and #{to} and lx='b'
</select>
<select id="wczl" resultType="BigDecimal">
SELECT SUM(case when zt>=62 then isnull(bclqzl,0)/1000 else 0 end) FROM dm_ydjh WHERE jssj
BETWEEN #{from} and #{to}
SELECT
SUM(case when zt>=62 then isnull(bclqzl,0)/1000 else 0 end)
FROM
dm_ydjh
WHERE
jssj BETWEEN #{from} and #{to} and lx='b'
</select>
</mapper>

Loading…
Cancel
Save