提交 ead90422 authored 作者: zhoushaopan's avatar zhoushaopan

feat(自查模块): 新增了日常检查流程

新增了日常检查流程
上级 22ab57ad
......@@ -57,6 +57,9 @@ public class WebMvcConfigConfig extends WebMvcConfigurationSupport {
@Value("${spring.jackson.local-date-format:yyyy-MM-dd}")
private String localDatePattern;
@Value("${qrcode.path}")
private String qrCodePath;
@Bean(name = "format")
DateTimeFormatter format() {
return DateTimeFormatter.ofPattern(formatValue);
......@@ -68,6 +71,7 @@ public class WebMvcConfigConfig extends WebMvcConfigurationSupport {
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/file/**").addResourceLocations("file:" + path);
registry.addResourceHandler("/code/**").addResourceLocations("file:" + qrCodePath);
//静态资源
registry.addResourceHandler( "/**" ).addResourceLocations( "classpath:/static/" );
// swagger handler
......
......@@ -865,7 +865,7 @@ public class DeviceLibraryController {
//添加装备日志
//修改型号就要修改列装id
PackingVo packingVo = libraryUpdateVo.getPackingVo();
String remarkModel = "将装备的型号由" + deviceLibraryEntity.getModel() + "改为" + packingVo.getModel();
String remarkModel = "将序列号为:"+deviceLibraryEntity.getSeqNumber()+"装备的型号由" + deviceLibraryEntity.getModel() + "改为" + packingVo.getModel();
String remarkType = "";
String remarkName = "";
String remarkMatchingRange = "";
......@@ -873,17 +873,17 @@ public class DeviceLibraryController {
deviceLibraryEntity.setPackingId(packingVo.getPackingId());
if (!deviceLibraryEntity.getName().equals(packingVo.getName())){
remarkName = "将装备的名称由" + deviceLibraryEntity.getName() + "改为" + packingVo.getName();
remarkName = "将序列号为:"+deviceLibraryEntity.getSeqNumber()+"装备的名称由" + deviceLibraryEntity.getName() + "改为" + packingVo.getName();
deviceLibraryEntity.setName(packingVo.getName());
}
//修改形态
if (!deviceLibraryEntity.getType().equals(packingVo.getType())){
remarkType= "将装备的形态由" + deviceLibraryEntity.getTypeName() + "改为" + packingVo.getTypeName();
remarkType= "将序列号为"+deviceLibraryEntity.getSeqNumber()+"装备的形态由" + deviceLibraryEntity.getTypeName() + "改为" + packingVo.getTypeName();
deviceLibraryEntity.setType(packingVo.getType());
}
//修改配用范围
if (!deviceLibraryEntity.getMatchingRange().equals(packingVo.getMatchingRange())){
remarkMatchingRange = "将装备的配用范围由" + deviceLibraryEntity.getMatchingRangeName() + "改为" + packingVo.getMatchingRangeName();
remarkMatchingRange = "将序列号为"+deviceLibraryEntity.getSeqNumber()+"装备的配用范围由" + deviceLibraryEntity.getMatchingRangeName() + "改为" + packingVo.getMatchingRangeName();
deviceLibraryEntity.setMatchingRange(packingVo.getMatchingRange());
}
String lastRemark = (remarkModel+remarkType+remarkName+remarkMatchingRange).replaceAll("\\\"", "");
......@@ -898,7 +898,7 @@ public class DeviceLibraryController {
list.add(units1.getUnitId());
list.add(units2.getUnitId());
List<Integer> userList = userCache.findAllByUnitsIdIn(list).stream().map(User::getUserId).collect(Collectors.toList());
MessageBto messageBto = new MessageBto(0, 0,userUtils.getCurrentUserUnitName()+lastRemark,
MessageBto messageBto = new MessageBto(0, 0,lastRemark,
userList,1,1);
messageService.add(messageBto);
}else {
......
......@@ -291,6 +291,7 @@ public class DeviceLibrary implements Serializable {
@ApiModelProperty(value = "状态",notes = "1 读取到 0 未读取到")
private Integer status;
// @Transient
// private DeviceLibraryPosition deviceLibraryPosition;
......
......@@ -49,6 +49,25 @@
<artifactId>commons-net</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.zxing/javase -->
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId>
<version>1.1.2.6</version>
</dependency>
</dependencies>
</project>
package com.tykj.dev.misc.qrcode;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 用于处理ZB传过来的数据
*
* @author Administrator
*/
public class DeviceDataUtil {
Map<Integer,String> stringMap = new HashMap<>();
int totalPage = -1;
/**
* 如果字符串完整了就返回True 否则返回 False
* @return 数据是否完整
*/
public Boolean addString(String str){
//解析当前页,总页数
// int firstFlagIndexOf = str.indexOf("Ǵ");
int firstFlagIndexOf = str.indexOf("!");
int currentPage = Integer.parseInt(str.substring(0,firstFlagIndexOf));
str = str.substring(firstFlagIndexOf+1);
// int secondFlagIndexOf = str.indexOf("Ǵ");
int secondFlagIndexOf = str.indexOf("!");
int totalPage = Integer.parseInt(str.substring(0, secondFlagIndexOf));
if (this.totalPage==-1){
this.totalPage = totalPage;
}
str = str.substring(secondFlagIndexOf+1);
stringMap.put(currentPage,str);
return stringMap.size() == totalPage;
}
public String getCompleteString(){
StringBuilder stringBuffer = new StringBuilder();
for (Integer integer : stringMap.keySet()) {
stringBuffer.append(stringMap.get(integer));
}
return stringBuffer.toString();
}
public static void main(String[] args) {
List<String> strings = new ArrayList<>();
strings.add("1!1!H4sIAAAAAAAAAKtWKkkszvZMUbIyMjQwNdABc/0Sc1OVrJSebZ35bOP853Man83Z9WJZ49ONDU/7J77Yuv35rJZn05c+3bHj2eKGZ/OXPtm9+2nXQiWI1pDKAqBWqDnORamJJakuQAw0zcjAyEjXwFTX0FLBwNjK0ACooTg5MQ8im1eak6OjlJJalpmc6pOZVJRYlJlarGQVXa2Um5+SmgNTkAd2GIRdArYJwk7OSE3ODkotLs0pAVtelJaZ4pxYlALylxLIotRCv9LcpNQiINfCwsLQxNTSyMzS0EypVoe2NpjT3AYLpdrYWgB+a8XlxgEAAA==");
DeviceDataUtil deviceDataUtil = new DeviceDataUtil();
for (int i = 0; i < strings.size(); i++) {
deviceDataUtil.addString(strings.get(i));
}
String json = GZIPUtils.uncompressToString(deviceDataUtil.getCompleteString());
System.out.println("json = " + json);
}
}
package com.tykj.dev.misc.qrcode;
/**
* @author zsp
* @create 2022/5/16 16:55
*/
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import org.springframework.util.Base64Utils;
public class GZIPUtils {
public static final String GZIP_ENCODE_UTF_8 = "UTF-8";
public static final String GZIP_ENCODE_ISO_8859_1 = "ISO-8859-1";
/**
* 字符串压缩为GZIP字节数组
* @param str
* @return
*/
public static String compress(String str) {
return compress(str, GZIP_ENCODE_UTF_8);
}
/**
* 字符串压缩为GZIP字节数组
* @param str
* @param encoding
* @return
*/
public static String compress(String str, String encoding) {
if (str == null || str.length() == 0) {
return null;
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
GZIPOutputStream gzip;
try {
gzip = new GZIPOutputStream(out);
gzip.write(str.getBytes(encoding));
gzip.close();
} catch (IOException e) {
e.printStackTrace();
}
return Base64Utils.encodeToString(out.toByteArray());
}
/**
* 解压并返回String
* @param data
* @return
*/
public static String uncompressToString(String data) {
return uncompressToString(data, GZIP_ENCODE_UTF_8);
}
/**
* 解压
* @param data
* @param encoding
* @return
*/
public static String uncompressToString(String data, String encoding) {
byte[] bytes = Base64Utils.decodeFromString(data);
if (bytes == null || bytes.length == 0) {
return null;
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
try {
GZIPInputStream ungzip = new GZIPInputStream(in);
byte[] buffer = new byte[256];
int n;
while ((n = ungzip.read(buffer)) >= 0) {
out.write(buffer, 0, n);
}
return out.toString(encoding);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public static void main(String[] args) {
List<String> strings = new ArrayList<>();
strings.add("1Ǵ1ǴH4sIAAAAAAAAAKtWKkkszvZMUbIyMjQwsNQBc/0Sc1OVrJSebZ35bOP853Man83Z9WJZ49ONDU/7J77Yuv35rJZn05c+3bHj2eKGZ/OXPtm9+2nXQiWI1pDKApBWQyjXuSg1sSTVBYiVrAzNTI0szAwNTSwNDAx0lIqTE/MgEnmlOTk6SimpZZnJqT6ZSUWJRZmpxRDhWgD5newOoAAAAA==");
DeviceDataUtil deviceDataUtil = new DeviceDataUtil();
for (int i = 0; i < strings.size(); i++) {
deviceDataUtil.addString(strings.get(i));
}
String json = GZIPUtils.uncompressToString(deviceDataUtil.getCompleteString());
}
}
package com.tykj.dev.misc.qrcode;
import com.google.zxing.*;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.google.zxing.qrcode.decoder.Version;
import com.google.zxing.qrcode.encoder.QRCode;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.geom.RoundRectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Random;
/**
* @author zsp
* @create 2022/4/27 13:19
*/
public class QRCodeUtil {
private static final String CHARSET = "utf-8";
private static final String FORMAT = "JPG";
// 二维码尺寸
private static final int QRCODE_SIZE = 400;
// LOGO宽度
private static final int LOGO_WIDTH = 60;
// LOGO高度
private static final int LOGO_HEIGHT = 60;
private static BufferedImage createImage(String content, String logoPath, boolean needCompress) throws Exception {
Hashtable<EncodeHintType, Object> hints = new Hashtable<EncodeHintType, Object>();
// hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
hints.put(EncodeHintType.CHARACTER_SET, CHARSET);
hints.put(EncodeHintType.MARGIN, 1);
QRCode qrCode = new QRCode();
qrCode.setVersion(Version.getVersionForNumber(30));
// qrCode.setVersion(Version.getVersionForNumber(35));
hints.put(EncodeHintType.QR_VERSION,qrCode.getVersion());
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, QRCODE_SIZE, QRCODE_SIZE,
hints);
int width = bitMatrix.getWidth();
int height = bitMatrix.getHeight();
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
image.setRGB(x, y, bitMatrix.get(x, y) ? 0xFF000000 : 0xFFFFFFFF);
}
}
if (logoPath == null || "".equals(logoPath)) {
return image;
}
// 插入图片
QRCodeUtil.insertImage(image, logoPath, needCompress);
return image;
}
/**
* 插入LOGO
*
* @param source
* 二维码图片
* @param logoPath
* LOGO图片地址
* @param needCompress
* 是否压缩
* @throws Exception
*/
private static void insertImage(BufferedImage source, String logoPath, boolean needCompress) throws Exception {
File file = new File(logoPath);
if (!file.exists()) {
throw new Exception("logo file not found.");
}
Image src = ImageIO.read(new File(logoPath));
int width = src.getWidth(null);
int height = src.getHeight(null);
if (needCompress) { // 压缩LOGO
if (width > LOGO_WIDTH) {
width = LOGO_WIDTH;
}
if (height > LOGO_HEIGHT) {
height = LOGO_HEIGHT;
}
Image image = src.getScaledInstance(width, height, Image.SCALE_SMOOTH);
BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = tag.getGraphics();
g.drawImage(image, 0, 0, null); // 绘制缩小后的图
g.dispose();
src = image;
}
// 插入LOGO
Graphics2D graph = source.createGraphics();
int x = (QRCODE_SIZE - width) / 2;
int y = (QRCODE_SIZE - height) / 2;
graph.drawImage(src, x, y, width, height, null);
Shape shape = new RoundRectangle2D.Float(x, y, width, width, 6, 6);
graph.setStroke(new BasicStroke(3f));
graph.draw(shape);
graph.dispose();
}
/**
* 生成二维码(内嵌LOGO)
* 二维码文件名随机,文件名可能会有重复
*
* @param content
* 内容
* @param logoPath
* LOGO地址
* @param destPath
* 存放目录
* @param needCompress
* 是否压缩LOGO
* @throws Exception
*/
public static String encode(String content, String logoPath, String destPath, boolean needCompress) throws Exception {
BufferedImage image = QRCodeUtil.createImage(content, logoPath, needCompress);
mkdirs(destPath);
String fileName = new Random().nextInt(99999999) + "." + FORMAT.toLowerCase();
ImageIO.write(image, FORMAT, new File(destPath + "/" + fileName));
return fileName;
}
/**
* 生成二维码(内嵌LOGO)
* 调用者指定二维码文件名
*
* @param content
* 内容
* @param logoPath
* LOGO地址
* @param destPath
* 存放目录
* @param fileName
* 二维码文件名
* @param needCompress
* 是否压缩LOGO
* @throws Exception
*/
public static String encode(String content, String logoPath, String destPath, String fileName, boolean needCompress) throws Exception {
BufferedImage image = QRCodeUtil.createImage(content, logoPath, needCompress);
mkdirs(destPath);
fileName = fileName.substring(0, fileName.indexOf(".")>0?fileName.indexOf("."):fileName.length())
+ "." + FORMAT.toLowerCase();
ImageIO.write(image, FORMAT, new File(destPath + "/" + fileName));
return fileName;
}
/**
* 当文件夹不存在时,mkdirs会自动创建多层目录,区别于mkdir.
* (mkdir如果父目录不存在则会抛出异常)
* @param destPath
* 存放目录
*/
public static void mkdirs(String destPath) {
File file = new File(destPath);
if (!file.exists() && !file.isDirectory()) {
file.mkdirs();
}
}
/**
* 生成二维码(内嵌LOGO)
*
* @param content
* 内容
* @param logoPath
* LOGO地址
* @param destPath
* 存储地址
* @throws Exception
*/
public static String encode(String content, String logoPath, String destPath) throws Exception {
return QRCodeUtil.encode(content, logoPath, destPath, false);
}
/**
* 生成二维码
*
* @param content
* 内容
* @param destPath
* 存储地址
* @param needCompress
* 是否压缩LOGO
* @throws Exception
*/
public static String encode(String content, String destPath, boolean needCompress) throws Exception {
return QRCodeUtil.encode(content, null, destPath, needCompress);
}
/**
* 生成二维码
*
* @param content
* 内容
* @param destPath
* 存储地址
* @throws Exception
*/
public static String encode(String content, String destPath) throws Exception {
return QRCodeUtil.encode(content, null, destPath, false);
}
/**
* 生成二维码(内嵌LOGO)
*
* @param content
* 内容
* @param logoPath
* LOGO地址
* @param output
* 输出流
* @param needCompress
* 是否压缩LOGO
* @throws Exception
*/
public static void encode(String content, String logoPath, OutputStream output, boolean needCompress)
throws Exception {
BufferedImage image = QRCodeUtil.createImage(content, logoPath, needCompress);
ImageIO.write(image, FORMAT, output);
}
/**
* 生成二维码
*
* @param content
* 内容
* @param output
* 输出流
* @throws Exception
*/
public static void encode(String content, OutputStream output) throws Exception {
QRCodeUtil.encode(content, null, output, false);
}
/**
* 解析二维码
*
* @param file
* 二维码图片
* @return
* @throws Exception
*/
public static String decode(File file) throws Exception {
BufferedImage image;
image = ImageIO.read(file);
if (image == null) {
return null;
}
BufferedImageLuminanceSource source = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Result result;
Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>();
hints.put(DecodeHintType.CHARACTER_SET, CHARSET);
result = new MultiFormatReader().decode(bitmap, hints);
String resultStr = result.getText();
return resultStr;
}
/**
* 解析二维码
*
* @param path
* 二维码图片地址
* @return
* @throws Exception
*/
public static String decode(String path) throws Exception {
return QRCodeUtil.decode(new File(path));
}
// public static void main(String[] args) throws Exception {
//
//// String text =
//// "也会心也会心中溢满快乐。伟大的哲学家康德,把人生的追求归结为:“我是谁?我要干什么?我能干什么?我如何去干?”幸福大概就是对这些问题的回答。能行风行风,能行雨行雨;能运筹帷幄,可当经理;有一身力气,蹬起三轮车也有歌声相伴。佛挡杀佛佛挡杀佛佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛杀佛杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛";
// String destPath = "C:\\Users\\zsp\\Desktop\\";
// String text =
// "佛佛佛法佛佛佛佛法佛佛佛佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛杀佛杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛挡杀佛佛佛法佛";
// System.out.println("text = " + text.length());
// byte[] bytes = text.getBytes(StandardCharsets.UTF_8);
// System.out.println("bytes = " + bytes.length);
// //不含Logo
// //文件先加密进行压缩
// byte[] compress = Snappy.compress(text.getBytes(StandardCharsets.UTF_8));
// System.out.println("compress = " + compress.length);
// QRCodeUtil.encode(text, null, destPath, true);
//// QRCodeUtil.encode(text, null, destPath, true);
//
//
// }
public static void main(String[] args) {
// List<DeviceLibrary> deviceLibraries = new ArrayList<>();
// DeviceLibrary deviceLibrary = new DeviceLibrary();
// deviceLibraries.add(deviceLibrary);
//先判断长度 1200字节一个二维码
// int totalRecord = deviceLibraries.size();
//其中maxResult-1就是totalRecord/maxResult的最大的余数
// totalPage = (totalRecord + maxResult -1) / maxResult;
// 总记录数:totalRecord
// 每页最大记录数:maxResult
// 总页数:totalPage
// int maxResult = 1200;
// int totalPage = (totalRecord + maxResult -1) / maxResult;
// for (int i = 0; i < totalPage; i++) {
//
// }
}
}
package com.tykj.dev.misc.qrcode;
import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.qrcode.vo.TaskData;
import com.tykj.dev.misc.utils.JacksonUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author zsp
* @create 2022/5/19 10:29
*/
@Slf4j
@Component
public class QrCodeBillUtil {
@Value("${qrcode.path}")
private String qrCodePath;
@Value("${qrcode.preview.path}")
private String qrCodePreviewPath;
/**
* 创建工具类
*/
public List<String> createCode(TaskData taskData){
String join = JacksonUtil.toJSon(taskData);
List<String> code = getCodeNum(join);
List<String> preview = new ArrayList<>();
//总页数
if (code.size() > 0) {
int totalPage = code.size();
for (int i = 0; i < totalPage; i++) {
//拼接字符串 定义好的格式:当前页+特殊符号+总页数+特殊符号+内容
String data = (i + 1) + "!" + code.size() + "!" + code.get(i);
log.info("data:{}",data);
//放在二维码里面
try {
String codePath = QRCodeUtil.encode(data, null, qrCodePath, false);
codePath = qrCodePreviewPath + codePath;
preview.add(codePath);
return preview;
} catch (Exception e) {
}
}
}
return new ArrayList<>();
}
public TaskData parseCode(List<String> strings){
DeviceDataUtil deviceDataUtil = new DeviceDataUtil();
List<String> collect = strings.stream().sorted(Comparator.comparing(s -> {
int i = s.indexOf("!");
s = s.substring(0,i);
return Integer.valueOf(s);
})).distinct().collect(Collectors.toList());
//循环判断
Boolean flag = false;
for (int i = 0; i < collect.size(); i++) {
flag = deviceDataUtil.addString(collect.get(i));
}
if (!flag){
throw new ApiException("没有扫完");
}
String json = GZIPUtils.uncompressToString(deviceDataUtil.getCompleteString());
//解析
TaskData taskData = JacksonUtil.readValue(json, TaskData.class);
return taskData;
}
/**
* 生成二维码的个数以及页数
*
* @param data 源数据
* @return 生成二维码的个数以及页数
*/
public List<String> getCodeNum(String data) {
//先压缩和加密
String s = GZIPUtils.compress(data);
//然后截取
return QrStringSplitUtil.stringToList2(s, 900);
}
}
package com.tykj.dev.misc.qrcode;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
/**
* @author zsp
* @create 2022/5/16 14:06
*/
public class QrStringSplitUtil {
public static List<String> stringToList2(String str,int maxResult){
List<String> list = new ArrayList<>();
//按照该长度进行字符串的分割
//将输入的字符串分割为几份
//总记录数:totalRecord
//每页最大记录数:maxResult
//其中maxResult-1就是totalRecord/maxResult的最大的余数
//总页数:totalPage
int totalRecord = str.length();
int totalPage = (totalRecord + maxResult -1) / maxResult;
//int size = str.length()/length+1;
System.out.println(totalRecord);
for (int i = 0; i < totalPage; i++) {
if (i==totalPage-1){
String substring = str.substring(i * maxResult, str.length());
list.add(substring);
}else {
String substring = str.substring(i * maxResult, (i + 1) * maxResult);
list.add(substring);
}
}
System.out.println(list);
return list;
}
public static String subString(String text, int start, int end, String encode) throws UnsupportedEncodingException {
//按照该长度进行字符串的分割
if( text == null || text == ""){
return null;
}
StringBuffer sb = new StringBuffer();
int currentLength = 0;
for( char c : text.toCharArray() )
{
currentLength += String_length(String.valueOf(c));
if( currentLength > start && currentLength <= end )
{
sb.append(c);
}else {
continue;
}
}
return sb.toString();
}
public static int String_length(String value) {
int valueLength = 0;
if (value!=null) {
String chinese = "[\u4e00-\u9fa5]";
for (int i = 0; i < value.length(); i++) {
String temp = value.substring(i, i + 1);
if (temp.matches(chinese)) {
valueLength += 2;
} else {
valueLength += 1;
}
}
}
return valueLength;
}
// public static void main(String[] args) throws UnsupportedEncodingException {
//// String str = "1234567890124564698797946532132132132156周";
// String str = "1中解大数据量的数量55";
// System.out.println("str = " + str.length());
// ArrayList<Object> objects = new ArrayList<>();
// //总记录数:totalRecord
// //每页最大记录数:maxResult
// //其中maxResult-1就是totalRecord/maxResult的最大的余数
// //总页数:totalPage
// int totalRecord = String_length(str);
// System.out.println("totalRecord = " + totalRecord);
// int maxResult = 7;
// int totalPage = (totalRecord + maxResult -1) / maxResult;
// for (int i = 1; i <= totalPage; i++) {
// String s = subString(str, (i-1)*maxResult, i*maxResult, "utf-8");
// System.out.println(s);
// objects.add(s);
// }
// System.out.println("split = " + objects);
// }
public static void main(String[] args) {
String str = "1234567890124564698797946532132132132156";
System.out.println("str = " + str.length());
List<String> list = stringToList2(str, 6);
System.out.println("list = " + list);
}
}
package com.tykj.dev.misc.qrcode.vo;
import lombok.Data;
/**
* @author zsp
* @create 2022/5/18 16:38
*/
@Data
public class DeviceCodeVO {
/**
* 型号
*/
private String model;
/**
* 装备名称
*/
private String name;
/**
* 类型
*/
private Integer type;
/**
* 检查结果(0:丢失,1:无误,2:新增)
*/
private Integer checkResult;
/**
* rfid卡号
*/
private String rfidCardId;
/**
* 序列号
*/
private String seqNumber;
}
package com.tykj.dev.misc.qrcode.vo;
import lombok.Data;
import java.util.List;
/**
* @author zsp
* @create 2022/5/16 13:18
*/
@Data
public class QrCodeVO {
private String data;
private Integer taskId;
/**
* 1 日常检查 0 常规检查
*/
private Integer type;
private String tas;
}
package com.tykj.dev.misc.qrcode.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List;
/**
* @author zsp
*/
@Data
public class TaskData {
public Integer taskId;
public String taskName;
/**
* 0 代表日常检查 1 自查 2 检查(核查的中的检查) 3 核查 4 出库 5入库
*/
public Integer taskType;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
public Date taskCreateDate;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
public Date scanDate;
List<DeviceCodeVO> deviceLibraries;
}
......@@ -6,6 +6,7 @@ import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.config.repository.SystemVariableDao;
import com.tykj.dev.config.service.SystemVariableService;
import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.file.entity.FileRet;
import com.tykj.dev.device.file.service.FilesUtil;
//import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.library.repository.DeviceLibraryDao;
......@@ -18,7 +19,9 @@ import com.tykj.dev.device.library.subject.vo.SelfCheckVo;
import com.tykj.dev.device.selfcheck.base.SelfCheckSchedulerTask;
import com.tykj.dev.device.selfcheck.repository.SelfCheckBillDao;
import com.tykj.dev.device.selfcheck.service.SelfCheckBillService;
import com.tykj.dev.device.selfcheck.service.SelfCheckUnitBillService;
import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckBill;
import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckUnitBill;
import com.tykj.dev.device.selfcheck.subject.vo.*;
import com.tykj.dev.device.task.service.TaskLogService;
import com.tykj.dev.device.task.service.TaskService;
......@@ -35,6 +38,7 @@ import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.base.BusinessEnum;
import com.tykj.dev.misc.base.StatusEnum;
import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.qrcode.vo.TaskData;
import com.tykj.dev.misc.utils.JacksonUtil;
import com.tykj.dev.misc.utils.ResultUtil;
import com.tykj.dev.misc.utils.StringSplitUtil;
......@@ -115,6 +119,9 @@ public class SelfCheckController {
@Resource
private DeviceLibraryDao deviceLibraryDao;
@Resource
private SelfCheckUnitBillService service;
/**
* 月度
*/
......@@ -716,6 +723,7 @@ public class SelfCheckController {
}
//add
selfExaminationBillEntity.setCheckFileList(FilesUtil.stringFileToList(selfExaminationBillEntity.getCheckFiles()));
//1.实体
list.add(selfExaminationBillEntity);
//获取自查详情
String str3 = selfExaminationBillEntity.getCheckDetail();
......@@ -756,18 +764,22 @@ public class SelfCheckController {
}
}
}
//2.添加新增不在系统的装备
list.add(newDeviceList);
//3.添加自查装备
list.add(libraryEntities1);
//添加业务日志
// 4添加业务日志
list.add(taskLogService.getByTaskId(taskBto.getId()));
if (selfExaminationBillEntity.getUnStockDetail()!=null){
//5 非在库
list.add(JacksonUtil.readValue(selfExaminationBillEntity.getUnStockDetail(), new TypeReference<List<DeviceLibrary>>() {
}));
}
else {
list.add(new ArrayList<>());
}
//6.添加task
list.add(taskBto.toVo());
return ResultUtil.success(list);
}
......@@ -807,7 +819,7 @@ public class SelfCheckController {
private SelfCheckBillService selfCheckBillService;
@ApiOperation(value = "是否保存自查任务", notes = "可以通过这个接口查询是否保存自查任务")
@ApiOperation(value = "模拟系统自查数据", notes = "模拟系统自查数据")
@GetMapping(value = "/test")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity toSave(){
......@@ -974,4 +986,167 @@ public class SelfCheckController {
return ResultUtil.success(map);
}
@ApiOperation(value = "发起日常检查业务", notes = "发起日常检查业务")
@PostMapping(value = "/addDayBill")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity addDayBill(@RequestBody @Validated SelfCheckSaveVo selfCheckSaveVo) {
//当前登录的用户ID
Integer currentUserId = userUtils.getCurrentUserId();
//当前登录的单位ID
Integer unitId = userUtils.getCurrentUnitId();
//当前登录的单位名称
String currentUserUnitName = userUtils.getCurrentUserUnitName();
//添加账单
SelfCheckBill selfExaminationBillEntity;
TaskBto taskBto;
if (selfCheckSaveVo.getTaskId()!=null){
taskBto = taskService.get(selfCheckSaveVo.getTaskId());
TaskDisposeUtil.isNotSubmit(taskBto.getBillStatus(),StatusEnum.WAIT_SELF_CHECK);
selfExaminationBillEntity = selfExaminationBillService.getOne(taskBto.getBillId());
selfExaminationBillEntity.setCheckTime(new Date());
//日常检查设备
List<DeviceLibrary> dayCheckList = selfCheckSaveVo.getDayCheckList();
if (dayCheckList !=null && dayCheckList.size()>0){
selfExaminationBillEntity.setDayCheckList(JacksonUtil.toJSon(selfCheckSaveVo.getDayCheckList()));
}
BeanUtils.copyProperties(selfCheckSaveVo,selfExaminationBillEntity);
if (selfCheckSaveVo.getUnStockDevices()!=null&&selfCheckSaveVo.getUnStockDevices().size()>0){
selfExaminationBillEntity.setUnStockDetail(JacksonUtil.toJSon(selfCheckSaveVo.getUnStockDevices()));
}
if (selfCheckSaveVo.getType()==1){
taskBto.setCustomInfo("扫码");
//添加涉及人员
taskService.addInvolveUser(taskBto,currentUserId);
}else {
throw new ApiException("type只能为0或1");
}
selfExaminationBillEntity.setTaskId(selfCheckSaveVo.getTaskId());
}
else {
//发起任务
selfExaminationBillEntity = selfCheckSaveVo.toDo();
selfExaminationBillEntity.setTitle(currentUserUnitName + "发起的日常检查任务");
selfExaminationBillEntity.setCheckUnit(currentUserUnitName);
selfExaminationBillEntity.setCheckUnitId(unitId);
//更新
selfCheckBillService.addEntity(selfExaminationBillEntity);
//发起任务
List<Integer> userIds = new ArrayList<>();
userIds.add(currentUserId);
taskBto = new TaskBto(StatusEnum.SELF_CHECK_CONFIRM.id, currentUserUnitName + "发起的日常检查任务",
null, ".", selfExaminationBillEntity.getId(), 4,
currentUserId, 0, null, userIds);
TaskBto taskBto1 = new TaskBto();
if (selfCheckSaveVo.getType()==1){
taskBto.setCustomInfo("扫码");
taskBto1 = taskService.start(taskBto);
//未检查
selfExaminationBillEntity.setCheckStatus(3);
selfExaminationBillEntity.setTaskId(taskBto1.getId());
}
}
List<DeviceLibrary> dayCheckList = selfCheckSaveVo.getDayCheckList();
if (dayCheckList != null && dayCheckList.size() >0){
selfExaminationBillEntity.setDayCheckList(JacksonUtil.toJSon(dayCheckList));
}
selfExaminationBillEntity.setUseraId(currentUserId);
selfExaminationBillEntity.setCreateUnitId(unitId);
selfExaminationBillService.update(selfExaminationBillEntity);
log.info("[自查模块]:发起日常检查");
return ResultUtil.success(selfExaminationBillEntity);
}
@ApiOperation(value = "保存和更新日常检查的装备列表", notes = "保存和更新日常检查的装备列表")
@PostMapping(value = "/saveDayDevice")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity saveDayDevice(@RequestBody SelfCheckUnitBill selfCheckUnitBill) {
SelfCheckUnitBill unitBill = service.add(selfCheckUnitBill);
return ResultUtil.success(unitBill);
}
@ApiOperation(value = "根据单位id查询日常检查选择的设备", notes = "根据单位id查询日常检查选择的设备")
@GetMapping(value = "/findByUnitId")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity findByUnitId() {
Integer unitId = userUtils.getCurrentUnitId();
SelfCheckUnitBill checkUnitBill = service.findByUnitId(unitId);
if (checkUnitBill != null){
checkUnitBill.setDeviceLibraryList(JacksonUtil.readValue(checkUnitBill.getDayDeviceList(), new TypeReference<List<DeviceLibrary>>() {
}));
}
return ResultUtil.success(checkUnitBill);
}
@ApiOperation(value = "生成二维码", notes = "生成二维码")
@PostMapping(value = "/createCode")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity createCode(@RequestBody TaskData taskData) {
List<String> qrcode = selfCheckBillService.createQrcode(taskData);
return ResultUtil.success(qrcode);
}
@ApiOperation(value = "解析二维码", notes = "解析二维码")
@PostMapping(value = "/parseCode")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity parseCode(@RequestBody List<String> strings) {
return ResultUtil.success(selfCheckBillService.parseQrCode(strings));
}
@ApiOperation(value = "更新日常检查(日常检查的完结)", notes = "更新日常检查(日常检查的完结)")
@PostMapping(value = "/updateDayCheck")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity updateDayCheck(@RequestBody DayVO dayVO) {
Integer billId = dayVO.getId();
SelfCheckBill selfCheckBill = selfCheckBillService.getOne(billId);
BeanUtils.copyProperties(dayVO,selfCheckBill);
Integer currentUserId = userUtils.getCurrentUserId();
Integer taskId = dayVO.getTaskId();
if (dayVO.getNewDeviceList() != null) {
//按新增不在系统的装备按rfid卡号拼接保存
StringBuilder stringBuffer = new StringBuilder();
stringBuffer.append(".");
for (String s : dayVO.getNewDeviceList()) {
stringBuffer.append(s);
stringBuffer.append(".");
}
selfCheckBill.setNewDeviceDetail(stringBuffer.toString());
}
//添加日志
String deviceIdDetail = dayVO.getCheckDetail();
String[] strings = deviceIdDetail.split("x");
List<FileVo> fileVoList = new ArrayList<>();
if(dayVO.getCheckFiles()!=null&&dayVO.getCheckFiles().size()>0) {
selfCheckBill.setCheckFiles(FilesUtil.stringFileToList(dayVO.getCheckFiles()));
dayVO.getCheckFiles().forEach(fileRet -> {
fileVoList.add(new FileVo("日常检查单", fileRet.getName(), fileRet.getPreviewPath()));
});
}
List<DeviceLogDto> deviceLogDtos = new ArrayList<>();
for (String s:strings) {
if (s.length()>=2) {
Integer id = Integer.parseInt(s.substring(0, s.length() - 1));
DeviceLogDto deviceLogDto = new DeviceLogDto(id,"发起日常检查",fileVoList,currentUserId,dayVO.getTaskId());
deviceLogDtos.add(deviceLogDto);
}
}
executor.execute(()->deviceLogService.addAllLog(deviceLogDtos));
TaskBto taskBto = taskService.get(taskId);
//任务推至完结
TaskBto taskBto1 = taskService.moveToEnd(taskBto);
//更新自查单
selfCheckBill.setCheckStatus(2);
selfCheckBill.setTaskId(taskBto1.getId());
SelfCheckBill save = selfCheckBillDao.save(selfCheckBill);
return ResultUtil.success(save);
}
@ApiOperation(value = "查询日常检查的详情", notes = "查询日常检查的详情")
@GetMapping(value = "/selectDetail")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity selectDetail(Integer billId) {
Map<String, Object> detail = selfCheckBillService.selectDetail(billId);
return ResultUtil.success(detail);
}
}
package com.tykj.dev.device.selfcheck.repository;
import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckUnitBill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author dengdiyi
*/
public interface SelfCheckUnitBillDao extends JpaRepository<SelfCheckUnitBill, Integer>, JpaSpecificationExecutor<SelfCheckUnitBill> {
/**
* 根据单位id进行查询
* @param unitId 单位id
* @return 实体对象
*/
SelfCheckUnitBill findByUnitId(Integer unitId);
}
......@@ -2,8 +2,10 @@ package com.tykj.dev.device.selfcheck.service;
import com.tykj.dev.device.file.entity.FileRet;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckBill;
import com.tykj.dev.device.selfcheck.subject.vo.SelfCheckSelectVo;
import com.tykj.dev.misc.qrcode.vo.TaskData;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
......@@ -44,4 +46,20 @@ public interface SelfCheckBillService {
* @return
*/
Map<String,List<FileRet>> getFileList(Integer taskId);
/**
* 生成二维码
* @param taskData
*/
// List<String> createQrcode(List<DeviceLibrary> deviceLibraryList);
// List<String> createQrcode(CreateCodeVO createCodeVO);
List<String> createQrcode(TaskData taskData);
/**
* 解析二维码
*/
List<DeviceLibrary> parseQrCode(List<String> strings);
Map<String,Object> selectDetail(Integer billId);
}
package com.tykj.dev.device.selfcheck.service;
import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckUnitBill;
/**
* @author zsp
*/
public interface SelfCheckUnitBillService {
SelfCheckUnitBill add(SelfCheckUnitBill selfCheckUnitBill);
SelfCheckUnitBill findByUnitId(Integer unitId);
}
package com.tykj.dev.device.selfcheck.service.impl;
import com.fasterxml.jackson.core.type.TypeReference;
import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.blockcha.subject.entity.BcHash;
......@@ -8,31 +9,48 @@ import com.tykj.dev.config.TaskBeanConfig;
import com.tykj.dev.config.base.FileName;
import com.tykj.dev.device.file.entity.FileRet;
import com.tykj.dev.device.file.service.FilesUtil;
import com.tykj.dev.device.library.service.DeviceLibraryCacheService;
import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.selfcheck.repository.SelfCheckBillDao;
import com.tykj.dev.device.selfcheck.service.SelfCheckBillService;
import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckBill;
import com.tykj.dev.device.selfcheck.subject.vo.SelfCheckSelectVo;
import com.tykj.dev.device.task.service.TaskLogService;
import com.tykj.dev.device.task.service.TaskService;
import com.tykj.dev.device.task.subject.bto.TaskBto;
import com.tykj.dev.device.task.subject.vo.TaskLogUserVo;
import com.tykj.dev.device.task.subject.vo.TaskUserVo;
import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.base.BusinessEnum;
import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.qrcode.*;
import com.tykj.dev.misc.qrcode.vo.DeviceCodeVO;
import com.tykj.dev.misc.qrcode.vo.TaskData;
import com.tykj.dev.misc.utils.JacksonUtil;
import com.tykj.dev.misc.utils.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.persistence.Transient;
import java.lang.reflect.Field;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author dengdiyi
*/
@Service
@Slf4j
public class SelfCheckBillServiceImpl implements SelfCheckBillService {
@Autowired
......@@ -47,10 +65,19 @@ public class SelfCheckBillServiceImpl implements SelfCheckBillService {
@Autowired
private TaskService taskService;
@Resource
DeviceLibraryCacheService deviceLibraryCacheService;
@Resource
private DeviceLibraryService deviceLibraryService;
@Resource
private TaskLogService taskLogService;
@Override
public SelfCheckBill addEntity(SelfCheckBill selfExaminationBillEntity) {
SelfCheckBill selfCheckBill = selfExaminationBillDao.save(selfExaminationBillEntity);
CompletableFuture.runAsync(()->{
CompletableFuture.runAsync(() -> {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
......@@ -82,7 +109,8 @@ public class SelfCheckBillServiceImpl implements SelfCheckBillService {
@Override
public SelfCheckBill update(SelfCheckBill selfExaminationBillEntity) {
SelfCheckBill selfCheckBill = selfExaminationBillDao.save(selfExaminationBillEntity);
CompletableFuture.runAsync(()->blockChainUtil.appendHash(JacksonUtil.toJSon(selfCheckBill),selfCheckBill.getRecordId()),TaskBeanConfig.getThreadPoolTaskScheduler());
CompletableFuture.runAsync(() -> blockChainUtil.appendHash(JacksonUtil.toJSon(selfCheckBill),
selfCheckBill.getRecordId()), TaskBeanConfig.getThreadPoolTaskScheduler());
return selfCheckBill;
}
......@@ -98,7 +126,8 @@ public class SelfCheckBillServiceImpl implements SelfCheckBillService {
@Override
public Page<SelfCheckBill> getPage(SelfCheckSelectVo selfCheckSelectVo, Pageable pageable) {
return selfExaminationBillDao.findAll(getSelectSpecification(selfCheckSelectVo), selfCheckSelectVo.getPageable());
return selfExaminationBillDao.findAll(getSelectSpecification(selfCheckSelectVo),
selfCheckSelectVo.getPageable());
}
@Override
......@@ -107,21 +136,22 @@ public class SelfCheckBillServiceImpl implements SelfCheckBillService {
}
@Override
public List<SelfCheckBill> findByDate(Date date,String unitName) {
return selfExaminationBillDao.findAllByCreateTimeAfterAndCheckUnitAndCheckStatusAndCreateUserId(date,unitName,3,null);
public List<SelfCheckBill> findByDate(Date date, String unitName) {
return selfExaminationBillDao.findAllByCreateTimeAfterAndCheckUnitAndCheckStatusAndCreateUserId(date,
unitName, 3, null);
}
@Override
public List<SelfCheckBill> findBySystem(String unitName) {
PredicateBuilder<SelfCheckBill> builder = Specifications.and();
builder.eq("checkUnit",unitName);
builder.eq("checkUnit", unitName);
return selfExaminationBillDao.findAll(builder.build());
}
private Specification<SelfCheckBill> getSelectSpecification(SelfCheckSelectVo selfCheckSelectVo) {
PredicateBuilder<SelfCheckBill> predicateBuilder = Specifications.and();
// predicateBuilder.eq("checkUnit",userUtils.getCurrentUserUnitName());
predicateBuilder.eq("checkUnitId",userUtils.getCurrentUnitId());
predicateBuilder.eq("checkUnitId", userUtils.getCurrentUnitId());
if (selfCheckSelectVo != null) {
if (selfCheckSelectVo.getCheckStatus() != null) {
predicateBuilder.eq("checkStatus", selfCheckSelectVo.getCheckStatus());
......@@ -171,7 +201,144 @@ public class SelfCheckBillServiceImpl implements SelfCheckBillService {
Integer billId = taskService.get(taskId).getBillId();
SelfCheckBill selfCheckBill = getOne(billId);
//自查单集合
map.put(FileName.SelfCheck.name, FilesUtil.stringFileToList(selfCheckBill.getCheckFiles()));
if (selfCheckBill.getCheckFiles() != null) {
map.put(FileName.SelfCheck.name, FilesUtil.stringFileToList(selfCheckBill.getCheckFiles()));
}
return map;
}
@Resource
private QrCodeBillUtil qrCodeBillUtil;
@Override
public List<String> createQrcode(TaskData taskData) {
List<String> code = qrCodeBillUtil.createCode(taskData);
return code;
}
@Override
public List<DeviceLibrary> parseQrCode(List<String> strings) {
//总的装备集合 返回给前端
TaskData taskData = qrCodeBillUtil.parseCode(strings);
List<DeviceLibrary> deviceLibraries = new ArrayList<>();
if (taskData != null) {
List<DeviceCodeVO> deviceLibraryList = taskData.getDeviceLibraries();
//0 缺失
List<DeviceCodeVO> libraryList =
deviceLibraryList.stream().filter(deviceCodeVO -> deviceCodeVO.getCheckResult() == 0).collect(Collectors.toList());
if (libraryList.size() > 0) {
List<String> seqList =
libraryList.stream().map(DeviceCodeVO::getSeqNumber).collect(Collectors.toList());
//缺失的设备
List<DeviceLibrary> lossDeviceList = deviceLibraryService.findAllBySeqNumber(seqList);
// List<DeviceLibrary> lossDeviceList = deviceLibraryService.findAllByRfids(seqList);
lossDeviceList.forEach(deviceLibrary -> {
//前端定义的是 2是新增 在selfcheckBill
deviceLibrary.setCheckResult(0);
});
deviceLibraries.addAll(lossDeviceList);
}
//正常的 1 正常的设备 2 新增的设备
List<DeviceCodeVO> normalList =
deviceLibraryList.stream().filter(deviceCodeVO -> deviceCodeVO.getCheckResult() == 1 )
.collect(Collectors.toList());
if (normalList.size() >0){
List<String> stringList = normalList.stream().map(DeviceCodeVO::getSeqNumber).collect(Collectors.toList());
List<DeviceLibrary> deviceLibraryList1 = deviceLibraryService.findAllBySeqNumber(stringList);
deviceLibraryList1.forEach(deviceLibrary -> deviceLibrary.setCheckResult(1));
deviceLibraries.addAll(deviceLibraryList1);
}
List<DeviceCodeVO> newList =
deviceLibraryList.stream().filter(deviceCodeVO -> deviceCodeVO.getCheckResult() == 2)
.collect(Collectors.toList());
if (newList.size() >0){
List<String> stringList = newList.stream().map(DeviceCodeVO::getSeqNumber).collect(Collectors.toList());
List<DeviceLibrary> deviceLibraryList1 = deviceLibraryService.findAllBySeqNumber(stringList);
deviceLibraryList1.forEach(deviceLibrary -> deviceLibrary.setCheckResult(2));
deviceLibraries.addAll(deviceLibraryList1);
}
}
return deviceLibraries;
}
@Override
public Map<String, Object> selectDetail(Integer billId) {
Map<Integer, DeviceLibrary> deviceLibraryMap =
deviceLibraryCacheService.getAllDeviceLibraryList().stream().collect(Collectors.toMap(DeviceLibrary::getId,
Function.identity()));
Map<String, Object> map = new HashMap<>();
//根据billid查询实体
SelfCheckBill checkBill = getOne(billId);
//日常设备信息
if (checkBill.getDayCheckList() != null) {
checkBill.setDayDeviceLibraries(JacksonUtil.readValue(checkBill.getDayCheckList(),
new TypeReference<List<DeviceLibrary>>() {
}));
}
//设备信息
List<DeviceLibrary> deviceLibraries = new ArrayList<>();
String checkDetail = checkBill.getCheckDetail();
if (checkDetail != null) {
String[] split = checkDetail.split("x");
//添加自查装备
for (String s : split) {
if (s.length() >= 2) {
Integer i = Integer.parseInt(s.substring(0, s.length() - 1));
Integer checkResult = Integer.parseInt(s.substring(s.length() - 1));
DeviceLibrary deviceLibraryEntity = deviceLibraryMap.get(i);
deviceLibraryEntity.setCheckResult(checkResult);
deviceLibraries.add(deviceLibraryEntity);
}
}
}
checkBill.setInDeviceLibraries(deviceLibraries);
//新增的
String newDeviceDetail = checkBill.getNewDeviceDetail();
List<DeviceLibrary> newDeviceList = new ArrayList<>();
if (newDeviceDetail != null) {
//分隔字符获得rfid卡号
String[] split2 = newDeviceDetail.split("\\.");
newDeviceList = new ArrayList<>();
for (String rfid : split2) {
if (rfid.length() > 0) {
DeviceLibrary d = new DeviceLibrary();
d.setCheckResult(2);
d.setSeqNumber("-");
d.setName("-");
d.setType(0);
d.setRfidSurfaceId("-");
d.setProdNumber("-");
d.setRfidCardId(rfid);
newDeviceList.add(d);
}
}
}
checkBill.setNewDeviceLibraries(newDeviceList);
//处理文件
if (checkBill.getCheckFiles() != null && checkBill.getCheckFiles().length() >0){
checkBill.setCheckFileList(FilesUtil.stringFileToList(checkBill.getCheckFiles()));
}
map.put("checkBill", checkBill);
//根据业务id查询任务日志
TaskBto taskBto = taskService.get(billId, BusinessEnum.SELF_CHECK.id);
List<TaskLogUserVo> taskLogUserVoList = taskLogService.getByTaskId(taskBto.getId());
map.put("taskLogUserVoList", taskLogUserVoList);
//查询任务
TaskUserVo taskUserVo = taskBto.toVo();
map.put("taskUserVo", taskUserVo);
return map;
}
public static void main(String[] args) {
List<String> strings = new ArrayList<>();
strings.add("11H4sIAAAAAAAAAKtWSkkty0xO9clMKkosykwtVrKKrlZKzkhNzg5KLS7NKVGyMtBRys1PSc1RslJ6Oq7af92QyUdpbzE3FSQwITe58s3gASK0jJTnBOLUjxTgMIG2IChsQFQXXFqoV9pblJqEX5lJZUFQPONanUIOcYI3TFGxDnGyJIox4CVwRwTC9SRnJjnklgCss7IwNBC18Bc19BAwdDQygBkb0licbZzUSpQHq7GyEDXwBCIFAwMrAwMoGpA7jI0gLD9II5/trX7xfqpT3bvftq10BCqLARsr0EtADONAy+lAQAA");
DeviceDataUtil deviceDataUtil = new DeviceDataUtil();
for (int i = 0; i < strings.size(); i++) {
deviceDataUtil.addString(strings.get(i));
}
String json = GZIPUtils.uncompressToString(deviceDataUtil.getCompleteString());
//解析
TaskData taskData = JacksonUtil.readValue(json, TaskData.class);
}
}
package com.tykj.dev.device.selfcheck.service.impl;
import com.tykj.dev.device.selfcheck.repository.SelfCheckUnitBillDao;
import com.tykj.dev.device.selfcheck.service.SelfCheckUnitBillService;
import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckUnitBill;
import com.tykj.dev.misc.utils.JacksonUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* @author zsp
* @create 2022/5/17 13:15
*/
@Service
public class SelfCheckUnitBillServiceImpl implements SelfCheckUnitBillService {
@Resource
private SelfCheckUnitBillDao selfCheckUnitBillDao;
@Override
public SelfCheckUnitBill add(SelfCheckUnitBill selfCheckUnitBill) {
selfCheckUnitBill.setDayDeviceList(JacksonUtil.toJSon(selfCheckUnitBill.getDeviceLibraryList()));
return selfCheckUnitBillDao.save(selfCheckUnitBill);
}
@Override
public SelfCheckUnitBill findByUnitId(Integer unitId) {
return selfCheckUnitBillDao.findByUnitId(unitId);
}
}
package com.tykj.dev.device.selfcheck.subject.domin;
import com.tykj.dev.device.file.entity.FileRet;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -147,6 +148,17 @@ public class SelfCheckBill {
@ApiModelProperty(value = "装备存放位置Id",notes = "默认是库房, null代表是所有库房")
private Integer storageLocationId;
@ApiModelProperty(value = "是否是日常检查",notes = "0代表 常规检查, 1代表 日常检查")
private Integer isDayCheck = 0;
// @ApiModelProperty(value = "生成二维码的地址")
// @Column(name = "qr_code_path",columnDefinition = "TEXT")
// private String qrcodePath ;
@ApiModelProperty(value = "日常检查装备的集合")
@Column(name = "day_check_list",columnDefinition = "TEXT")
private String dayCheckList;
@ApiModelProperty(value = "装备存放位置Id",notes = "默认是库房, null代表是所有库房")
@Transient
private String storageLocationName;
......@@ -179,4 +191,20 @@ public class SelfCheckBill {
@Transient
private Integer taskId;
@Transient
@ApiModelProperty(name = "")
private Integer taskCreateDate;
@Transient
@ApiModelProperty("日常检查的设备列表")
private List<DeviceLibrary> dayDeviceLibraries;
@Transient
@ApiModelProperty("日常检查设备信息列表")
private List<DeviceLibrary> inDeviceLibraries;
@Transient
@ApiModelProperty("日常检查的设备新增设备列表")
private List<DeviceLibrary> newDeviceLibraries;
}
package com.tykj.dev.device.selfcheck.subject.domin;
import com.tykj.dev.device.file.entity.FileRet;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* entity class for self_examination_bill
*
* @author zsp
*/
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update self_check_unit_bill set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@ApiModel("日常检查和单位的表")
public class SelfCheckUnitBill {
/**
* 主键id
*/
@Id
@GeneratedValue
@ApiModelProperty(name = "主键id")
@Column(columnDefinition = "integer NOT NULL AUTO_INCREMENT")
private Integer id;
/**
* 自查周期(1:月度,2:季度,3:年度,0:未设定周期)
*/
@ApiModelProperty(value = "单位id")
private Integer unitId;
/**
* 自查标题
*/
@ApiModelProperty(value = "装备记录详情")
@Column(name = "day_device_list",columnDefinition = "TEXT")
private String dayDeviceList;
/**
* 创建用户id
*/
@CreatedBy
@ApiModelProperty(value = "创建用户id")
private Integer createUserId;
/**
* 创建时间
*/
@CreatedDate
@ApiModelProperty(value = "创建时间")
private Date createTime;
/**
* 更新时间
*/
@LastModifiedDate
@ApiModelProperty(value = "更新时间")
private Date updateTime;
/**
* 删除标记(0:未删除,1:已删除)
*/
@ApiModelProperty(value = "删除标记(0:未删除,1:已删除)")
private Integer deleteTag = 0;
@Transient
@ApiModelProperty(value = "选中的系统装备列表")
private List<DeviceLibrary> deviceLibraryList;
}
package com.tykj.dev.device.selfcheck.subject.vo;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Min;
import java.util.List;
/**
* @author zsp
*/
@Data
@ApiModel("生成二维码的vo")
public class CreateCodeVO {
@ApiModelProperty(name = "1 日常检查 0 常规检查 ", example = "1")
private Integer type;
@Min(value = 1,message = "taskId不能小于1")
@ApiModelProperty(name = "任务id", example = "1")
private Integer taskId;
@ApiModelProperty(name = "任务名称", example = "1")
private String taskName;
@ApiModelProperty(value = "装备集合")
private List<DeviceLibrary> deviceLibraryList;
}
package com.tykj.dev.device.selfcheck.subject.vo;
import com.tykj.dev.device.file.entity.FileRet;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @author dengdiyi
*/
@Data
@ApiModel("更新日常检查的vo")
public class DayVO {
@ApiModelProperty(name = "业务id")
private Integer id;
@ApiModelProperty(value = "非在库装备集合")
private List<DeviceLibrary> unStockDevices;
@ApiModelProperty(name = "新增未记录装备RFID列表")
private List<String> newDeviceList;
@ApiModelProperty(value = "检查附件名")
private List<FileRet> checkFiles;
@ApiModelProperty(name = "自查详情", example = "10x21x", value = "自查详情(装备主键id+核对结果(0缺失1无误2新增,字符x作为分隔符)),例如10x21x32,意为主键id为1的装备缺失,为2的无误,为3的新增")
private String checkDetail;
@NotNull(message = "checkedCount不能为空")
@Min(value = 0,message = "checkedCount不能小于0")
@ApiModelProperty(name = "实查数量", example = "1")
private Integer checkedCount;
@ApiModelProperty(name = "任务id")
private Integer taskId;
@ApiModelProperty(value = "手持终端信息")
private String handheldTerminalInformation;
@ApiModelProperty(name = "自查结果", example = "数量x0 0 缺失 1无误 2 新增")
private String checkResult;
}
......@@ -42,16 +42,16 @@ public class SelfCheckSaveVo {
@ApiModelProperty(name = "应查数量", example = "1")
private Integer checkingCount;
@NotNull(message = "checkedCount不能为空")
// @NotNull(message = "checkedCount不能为空")
@Min(value = 0,message = "checkedCount不能小于0")
@ApiModelProperty(name = "实查数量", example = "1")
private Integer checkedCount;
@NotNull(message = "checkResult不能为空")
// @NotNull(message = "checkResult不能为空")
@ApiModelProperty(name = "自查结果", example = "通过")
private String checkResult;
@NotNull(message = "checkDetail不能为空")
// @NotNull(message = "checkDetail不能为空")
@ApiModelProperty(name = "自查详情", example = "10x21x", value = "自查详情(装备主键id+核对结果(0缺失1无误2新增,字符x作为分隔符)),例如10x21x32,意为主键id为1的装备缺失,为2的无误,为3的新增")
private String checkDetail;
......@@ -67,6 +67,12 @@ public class SelfCheckSaveVo {
@ApiModelProperty(value = "手持终端信息")
private String handheldTerminalInformation;
@ApiModelProperty(value = "是否是日常检查",notes = "0代表 常规检查, 1代表 日常检查")
private Integer isDayCheck = 0;
@ApiModelProperty(value = "日常检查装备的集合")
private List<DeviceLibrary> dayCheckList ;
public SelfCheckBill toDo() {
SelfCheckBill selfExaminationBillEntity = new SelfCheckBill();
BeanUtils.copyProperties(this, selfExaminationBillEntity);
......
......@@ -113,6 +113,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers("/logout/impersonate*").permitAll()
.antMatchers("/packageVersion/getVersion","/equip/packageVersion/getVersion").permitAll()//
.antMatchers("/equip/file/llq/**").permitAll()
.antMatchers("/code/**","/equip/code/**").permitAll()
.antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
// .withObjectPostProcessor(new ObjectPostProcessor<FilterSecurityInterceptor>() {
// @Override
......@@ -155,7 +156,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) {
//swagger静态资源访问
web.ignoring().antMatchers("/v2/api-docs", "/v2/api-docs-ext", "/configuration/ui", "/swagger-resources/**", "/configuration/security", "/swagger-ui/", "/swagger-ui/**", "/swagger-ui.html", "/doc.html", "/webjars/**", "/swagger-resources/configuration/ui", "**/swagge‌​r-ui.html", "/static/**", "**/**/index.html", "**/index.html", "/**/index.html", "/js/**", "/css/**", "/fonds/**", "/img/**","/access/send","/user/s");
web.ignoring().antMatchers("/v2/api-docs", "/v2/api-docs-ext", "/configuration/ui", "/swagger-resources/**", "/configuration/security", "/swagger-ui/", "/swagger-ui/**", "/swagger-ui.html", "/doc.html", "/webjars/**", "/swagger-resources/configuration/ui", "**/swagger-ui.html", "/static/**", "**/**/index.html", "**/index.html", "/**/index.html", "/js/**", "/css/**", "/fonds/**", "/img/**","/access/send","/user/s");
}
@Bean
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论