Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 67b9074557 | |||
| db0f4af506 | |||
| 1cdc297a9b | |||
| f9306c82d5 | |||
| 2be6c852ef | |||
| 2183a89192 | |||
| a1e863568b | |||
| 552c19bfeb | |||
| 49d213e988 |
54
pom.xml
54
pom.xml
@ -319,60 +319,6 @@
|
||||
<version>2.1.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- opencv -->
|
||||
<dependency>
|
||||
<groupId>org.bytedeco</groupId>
|
||||
<artifactId>javacv-platform</artifactId>
|
||||
<version>1.4.4</version>
|
||||
</dependency>
|
||||
<!-- 虹软人脸识别 -->
|
||||
<dependency>
|
||||
<groupId>com.arcsoft.face</groupId>
|
||||
<artifactId>arcsoft</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/src/main/resources/lib/arcsoft-sdk-face-3.0.0.0.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<!-- 服务器端推理引擎 -->
|
||||
<dependency>
|
||||
<groupId>ai.djl</groupId>
|
||||
<artifactId>api</artifactId>
|
||||
<version>${djl.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ai.djl</groupId>
|
||||
<artifactId>basicdataset</artifactId>
|
||||
<version>${djl.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ai.djl</groupId>
|
||||
<artifactId>model-zoo</artifactId>
|
||||
<version>${djl.version}</version>
|
||||
</dependency>
|
||||
<!-- MXNet -->
|
||||
<dependency>
|
||||
<groupId>ai.djl.mxnet</groupId>
|
||||
<artifactId>mxnet-model-zoo</artifactId>
|
||||
<version>${djl.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ai.djl.mxnet</groupId>
|
||||
<artifactId>mxnet-engine</artifactId>
|
||||
<version>${djl.version}</version>
|
||||
</dependency>
|
||||
<!-- Pytorch -->
|
||||
<dependency>
|
||||
<groupId>ai.djl.pytorch</groupId>
|
||||
<artifactId>pytorch-engine</artifactId>
|
||||
<version>${djl.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ai.djl.pytorch</groupId>
|
||||
<artifactId>pytorch-model-zoo</artifactId>
|
||||
<version>${djl.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- mqtt -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
|
||||
@ -107,7 +107,7 @@ public class Aes {
|
||||
cipher.init(Cipher.DECRYPT_MODE, skey);
|
||||
byte[] result = cipher.doFinal(new Base64().decode(content));
|
||||
// 解密
|
||||
return new String(result);
|
||||
return new String(result, "UTF-8");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
@ -115,9 +115,9 @@ public class Aes {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String content = "RaxMRsBUfFDjz_U_7LB_TJHqPNDVlpiOtkdqhZMTDoW3bHbfHnQ8_wuKIcVJemVn".replace("-", "+").replace("_", "/");
|
||||
String content = "grWn9TcbYmxu0KjA5utvyX38gGTPleC86M5PM8CuFmnqBaSNY0UV2xjn4EyijUZdkQtOPmES+ElFMTEXaiWo0Q==";
|
||||
// System.out.println("RaxMRsBUfFDjz/U/7LB/TBRIDE/1I6ZZ9kmQFWqgLCID42evqzeC8kpDSd3GM7YB".replace("+", "-").replace("/", "_"));
|
||||
// System.out.println(encrypt("{\"uid\":\"test\",\"exp\":1686559180478}", "ssologin66!@#$%^"));
|
||||
System.out.println(decrypt(content, "ssologin66!@#$%^"));
|
||||
System.out.println(decrypt(content, KEY));
|
||||
}
|
||||
}
|
||||
@ -97,11 +97,6 @@ public class DataScopeHandler implements DataPermissionHandler {
|
||||
inExpression(getAliasColumn(plainSelect, getEngineeringSn()), engineeringSns, plainSelect);
|
||||
}
|
||||
if (user.getAccountType() == 2) {
|
||||
Expression plainSelectWhere = plainSelect.getWhere();
|
||||
String whereString = plainSelectWhere.toString();
|
||||
if (!whereString.contains(getEngineeringSn() + " =") && !plainSelect.getFromItem().toString().split(" ")[0].equals("engineering")) {
|
||||
equalsTo(getAliasColumn(plainSelect, getEngineeringSn()), "", plainSelect);
|
||||
}
|
||||
List<String> projectSns = projectService.getSnListForGov(user.getSn());
|
||||
if (projectSns.size() == 0) {
|
||||
projectSns.add("0");
|
||||
|
||||
@ -26,10 +26,14 @@ public class AsyncEmail {
|
||||
*/
|
||||
@Async("taskExecutor")
|
||||
public void sendEmail(String sn, String receiveUser, String title, String content) {
|
||||
GovernmentConfig governmentConfig = governmentConfigService.getOne(Wrappers.<GovernmentConfig>lambdaQuery().eq(GovernmentConfig::getGovernmentSn, sn)
|
||||
.eq(GovernmentConfig::getKey, ParamEnum.GovernmentConfig.EMAIL.getValue()));
|
||||
if (governmentConfig != null && StringUtils.isNotBlank(governmentConfig.getValue())) {
|
||||
EmailsUtil.send(governmentConfig.getValue(), receiveUser, title, content);
|
||||
try {
|
||||
GovernmentConfig governmentConfig = governmentConfigService.getOne(Wrappers.<GovernmentConfig>lambdaQuery().eq(GovernmentConfig::getGovernmentSn, sn)
|
||||
.eq(GovernmentConfig::getConfigKey, ParamEnum.GovernmentConfig.EMAIL.getValue()));
|
||||
if (governmentConfig != null && StringUtils.isNotBlank(governmentConfig.getValue())) {
|
||||
EmailsUtil.send(governmentConfig.getValue(), receiveUser, title, content);
|
||||
}
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,14 +1,6 @@
|
||||
package com.zhgd.xmgl.config;
|
||||
|
||||
import com.arcsoft.face.ActiveFileInfo;
|
||||
import com.arcsoft.face.EngineConfiguration;
|
||||
import com.arcsoft.face.FaceEngine;
|
||||
import com.arcsoft.face.FunctionConfiguration;
|
||||
import com.arcsoft.face.enums.DetectMode;
|
||||
import com.arcsoft.face.enums.DetectOrient;
|
||||
import com.arcsoft.face.enums.ErrorInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -25,68 +17,68 @@ import org.springframework.stereotype.Component;
|
||||
@Slf4j
|
||||
public class FaceRunner implements CommandLineRunner {
|
||||
|
||||
public static FaceEngine faceEngine;
|
||||
@Value("${arcsoft.appId}")
|
||||
private String appId;
|
||||
@Value("${arcsoft.sdkKey}")
|
||||
private String winsSdkKey;
|
||||
@Value("${arcsoft.linux.sdkKey}")
|
||||
private String linuxSdkKey;
|
||||
@Value("${arcsoft.dllPath}")
|
||||
private String dllPath;
|
||||
// public static FaceEngine faceEngine;
|
||||
// @Value("${arcsoft.appId}")
|
||||
// private String appId;
|
||||
// @Value("${arcsoft.sdkKey}")
|
||||
// private String winsSdkKey;
|
||||
// @Value("${arcsoft.linux.sdkKey}")
|
||||
// private String linuxSdkKey;
|
||||
// @Value("${arcsoft.dllPath}")
|
||||
// private String dllPath;
|
||||
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
String os = System.getProperty("os.name");
|
||||
log.info("服务器系统" + os);
|
||||
//如果是Windows系统
|
||||
if (os.toLowerCase().startsWith("win") || os.toLowerCase().startsWith("linux")) {
|
||||
String sdkKey = "";
|
||||
if (os.toLowerCase().startsWith("linux")) {
|
||||
sdkKey = linuxSdkKey;
|
||||
} else {
|
||||
sdkKey = winsSdkKey;
|
||||
}
|
||||
//log.info(HCNetSDKPath.DLL_PATH+"dll");
|
||||
log.info(dllPath);
|
||||
faceEngine = new FaceEngine(dllPath);
|
||||
//激活引擎
|
||||
int errorCode = faceEngine.activeOnline(appId, sdkKey);
|
||||
|
||||
if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
||||
log.info("引擎激活失败,errorCode:" + errorCode);
|
||||
}
|
||||
|
||||
|
||||
ActiveFileInfo activeFileInfo = new ActiveFileInfo();
|
||||
errorCode = faceEngine.getActiveFileInfo(activeFileInfo);
|
||||
if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
||||
log.info("获取激活文件信息失败");
|
||||
}
|
||||
|
||||
//引擎配置
|
||||
EngineConfiguration engineConfiguration = new EngineConfiguration();
|
||||
engineConfiguration.setDetectMode(DetectMode.ASF_DETECT_MODE_IMAGE);
|
||||
engineConfiguration.setDetectFaceOrientPriority(DetectOrient.ASF_OP_ALL_OUT);
|
||||
engineConfiguration.setDetectFaceMaxNum(10);
|
||||
engineConfiguration.setDetectFaceScaleVal(16);
|
||||
//功能配置
|
||||
FunctionConfiguration functionConfiguration = new FunctionConfiguration();
|
||||
functionConfiguration.setSupportAge(true);
|
||||
functionConfiguration.setSupportFace3dAngle(true);
|
||||
functionConfiguration.setSupportFaceDetect(true);
|
||||
functionConfiguration.setSupportFaceRecognition(true);
|
||||
functionConfiguration.setSupportGender(true);
|
||||
functionConfiguration.setSupportLiveness(true);
|
||||
functionConfiguration.setSupportIRLiveness(true);
|
||||
engineConfiguration.setFunctionConfiguration(functionConfiguration);
|
||||
//初始化引擎
|
||||
errorCode = faceEngine.init(engineConfiguration);
|
||||
|
||||
if (errorCode != ErrorInfo.MOK.getValue()) {
|
||||
log.info("初始化引擎失败");
|
||||
}
|
||||
}
|
||||
// String os = System.getProperty("os.name");
|
||||
// log.info("服务器系统" + os);
|
||||
// //如果是Windows系统
|
||||
// if (os.toLowerCase().startsWith("win") || os.toLowerCase().startsWith("linux")) {
|
||||
// String sdkKey = "";
|
||||
// if (os.toLowerCase().startsWith("linux")) {
|
||||
// sdkKey = linuxSdkKey;
|
||||
// } else {
|
||||
// sdkKey = winsSdkKey;
|
||||
// }
|
||||
// //log.info(HCNetSDKPath.DLL_PATH+"dll");
|
||||
// log.info(dllPath);
|
||||
// faceEngine = new FaceEngine(dllPath);
|
||||
// //激活引擎
|
||||
// int errorCode = faceEngine.activeOnline(appId, sdkKey);
|
||||
//
|
||||
// if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
||||
// log.info("引擎激活失败,errorCode:" + errorCode);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// ActiveFileInfo activeFileInfo = new ActiveFileInfo();
|
||||
// errorCode = faceEngine.getActiveFileInfo(activeFileInfo);
|
||||
// if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
||||
// log.info("获取激活文件信息失败");
|
||||
// }
|
||||
//
|
||||
// //引擎配置
|
||||
// EngineConfiguration engineConfiguration = new EngineConfiguration();
|
||||
// engineConfiguration.setDetectMode(DetectMode.ASF_DETECT_MODE_IMAGE);
|
||||
// engineConfiguration.setDetectFaceOrientPriority(DetectOrient.ASF_OP_ALL_OUT);
|
||||
// engineConfiguration.setDetectFaceMaxNum(10);
|
||||
// engineConfiguration.setDetectFaceScaleVal(16);
|
||||
// //功能配置
|
||||
// FunctionConfiguration functionConfiguration = new FunctionConfiguration();
|
||||
// functionConfiguration.setSupportAge(true);
|
||||
// functionConfiguration.setSupportFace3dAngle(true);
|
||||
// functionConfiguration.setSupportFaceDetect(true);
|
||||
// functionConfiguration.setSupportFaceRecognition(true);
|
||||
// functionConfiguration.setSupportGender(true);
|
||||
// functionConfiguration.setSupportLiveness(true);
|
||||
// functionConfiguration.setSupportIRLiveness(true);
|
||||
// engineConfiguration.setFunctionConfiguration(functionConfiguration);
|
||||
// //初始化引擎
|
||||
// errorCode = faceEngine.init(engineConfiguration);
|
||||
//
|
||||
// if (errorCode != ErrorInfo.MOK.getValue()) {
|
||||
// log.info("初始化引擎失败");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,42 +0,0 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.api.arcsoft_face;
|
||||
|
||||
import com.arcsoft.face.FaceFeature;
|
||||
import com.arcsoft.face.FaceInfo;
|
||||
import com.arcsoft.face.toolkit.ImageInfo;
|
||||
import com.zhgd.xmgl.modules.basicdata.api.arcsoft_face.handler.FacesHandler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import static com.arcsoft.face.toolkit.ImageFactory.getRGBData;
|
||||
|
||||
@Component
|
||||
public class FaceApi {
|
||||
|
||||
@Autowired
|
||||
private FacesHandler facesHandler;
|
||||
/**
|
||||
* 人像比对(图片和图片)
|
||||
* @param idCardFront 身份证图片
|
||||
* @param feature 人像图片
|
||||
*/
|
||||
public float compareFaceFeature(String idCardFront, String feature) {
|
||||
try {
|
||||
ImageInfo imageInfo = getRGBData(new File(idCardFront));
|
||||
ImageInfo imageInfo1 = getRGBData(new File(feature));
|
||||
// 人脸检测
|
||||
List<FaceInfo> faceInfos = facesHandler.detectFaces(imageInfo);
|
||||
List<FaceInfo> faceInfos1 = facesHandler.detectFaces(imageInfo1);
|
||||
// 特征提取
|
||||
FaceFeature faceFeature = facesHandler.extractFaceFeature(imageInfo, faceInfos);
|
||||
FaceFeature faceFeature1 = facesHandler.extractFaceFeature(imageInfo1, faceInfos1);
|
||||
// 特征对比
|
||||
return facesHandler.compareFaceFeature(faceFeature, faceFeature1);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("比对失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,64 +0,0 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.api.arcsoft_face.handler;
|
||||
|
||||
import com.arcsoft.face.FaceFeature;
|
||||
import com.arcsoft.face.FaceInfo;
|
||||
import com.arcsoft.face.FaceSimilar;
|
||||
import com.arcsoft.face.toolkit.ImageInfo;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.zhgd.xmgl.config.FaceRunner.faceEngine;
|
||||
|
||||
|
||||
@Component
|
||||
public class FacesHandler {
|
||||
|
||||
/**
|
||||
* 人脸检测
|
||||
* @param imageInfo
|
||||
* @return
|
||||
*/
|
||||
public List<FaceInfo> detectFaces(ImageInfo imageInfo) {
|
||||
List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
||||
int resultCode = faceEngine.detectFaces(imageInfo.getImageData(),
|
||||
imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(),
|
||||
faceInfoList);
|
||||
return (faceInfoList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 人脸特征提取
|
||||
* @param imageInfo
|
||||
* @param faceInfoList
|
||||
* @return
|
||||
*/
|
||||
public FaceFeature extractFaceFeature(ImageInfo imageInfo, List<FaceInfo> faceInfoList) {
|
||||
FaceFeature faceFeature = new FaceFeature();
|
||||
int resultCode = faceEngine.extractFaceFeature(imageInfo.getImageData(),
|
||||
imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(),
|
||||
faceInfoList.get(0), faceFeature);
|
||||
return faceFeature;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 人脸比对
|
||||
* @param faceFeature
|
||||
* @param faceFeature1
|
||||
* @return
|
||||
*/
|
||||
public float compareFaceFeature(FaceFeature faceFeature, FaceFeature faceFeature1) {
|
||||
FaceFeature targetFaceFeature = new FaceFeature();
|
||||
targetFaceFeature.setFeatureData(faceFeature.getFeatureData());
|
||||
FaceFeature sourceFaceFeature = new FaceFeature();
|
||||
sourceFaceFeature.setFeatureData(faceFeature1.getFeatureData());
|
||||
FaceSimilar faceSimilar = new FaceSimilar();
|
||||
int resultCode = faceEngine.compareFaceFeature(targetFaceFeature, sourceFaceFeature,
|
||||
faceSimilar);
|
||||
System.out.println("比对结果:相似度:" + faceSimilar.getScore());
|
||||
return faceSimilar.getScore();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,53 +0,0 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.api.image_ai;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.zhgd.xmgl.modules.basicdata.api.image_ai.common.FireSmokeDetectExample;
|
||||
import com.zhgd.xmgl.modules.basicdata.api.image_ai.common.MediumSafetyHelmetDetectExample;
|
||||
import com.zhgd.xmgl.modules.basicdata.api.image_ai.common.ReflectiveVestDetectExample;
|
||||
import com.zhgd.xmgl.modules.basicdata.api.image_ai.utils.AiBroker;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
@UtilityClass
|
||||
public class ImageApi {
|
||||
|
||||
/**
|
||||
* 根据rtsp流进行安全帽检测
|
||||
* @return
|
||||
*/
|
||||
public JSONArray safetyHelmet(String rtsp) {
|
||||
String result = AiBroker.runAs(rtsp, imagePath -> {
|
||||
return MediumSafetyHelmetDetectExample.imageAi(imagePath);
|
||||
});
|
||||
return JSONArray.parseArray(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据rtsp流进行反光衣检测
|
||||
* @return
|
||||
*/
|
||||
public JSONArray reflectiveVest(String rtsp) {
|
||||
String result = AiBroker.runAs(rtsp, imagePath -> {
|
||||
return ReflectiveVestDetectExample.imageAi(imagePath);
|
||||
});
|
||||
return JSONArray.parseArray(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据rtsp流进行烟火检测
|
||||
* @return
|
||||
*/
|
||||
public JSONArray fireSmoke(String rtsp) {
|
||||
String result = AiBroker.runAs(rtsp, imagePath -> {
|
||||
return FireSmokeDetectExample.imageAi(imagePath);
|
||||
});
|
||||
return JSONArray.parseArray(result);
|
||||
}
|
||||
|
||||
public static void main(String[] argstia) {
|
||||
try {
|
||||
System.out.println(reflectiveVest("rtsp://admin:jxj12345@10.0.77.104:554/Streaming/Channels/101"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,135 +0,0 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.api.image_ai;
|
||||
|
||||
import com.zhgd.xmgl.util.CommonUtil;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bytedeco.javacpp.Loader;
|
||||
import org.bytedeco.javacpp.opencv_core;
|
||||
import org.bytedeco.javacpp.opencv_java;
|
||||
import org.bytedeco.javacv.FFmpegFrameGrabber;
|
||||
import org.bytedeco.javacv.Frame;
|
||||
import org.bytedeco.javacv.OpenCVFrameConverter;
|
||||
import org.opencv.highgui.HighGui;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* opencv通过rtsp流截取图片
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@UtilityClass
|
||||
public class Opencv {
|
||||
|
||||
/**
|
||||
* 生成图片地址
|
||||
*/
|
||||
@Value("${opencv.filePath}")
|
||||
private String filePath;
|
||||
|
||||
public static void main(String[] args) {
|
||||
createImage("rtsp://admin:jxj12345@10.0.77.104:554/Streaming/Channels/101");
|
||||
}
|
||||
|
||||
public String createImage(String rtsp) {
|
||||
return createImage(rtsp, 1920, 1080);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param rtsp 流
|
||||
* @param imageWid 生成图片宽度
|
||||
* @param imageHei 生成图片高度
|
||||
* @return
|
||||
*/
|
||||
public String createImage(String rtsp, int imageWid, int imageHei) {
|
||||
if (filePath == null) {
|
||||
filePath = "D://opencv//";
|
||||
}
|
||||
log.info("==========opencv start=============");
|
||||
log.info("rtsp:" + rtsp + ";filePath: " + filePath);
|
||||
Loader.load(opencv_java.class);
|
||||
FFmpegFrameGrabber grabber = null;
|
||||
try {
|
||||
grabber = FFmpegFrameGrabber.createDefault(rtsp);
|
||||
grabber.setOption("rtsp_transport", "tcp"); // 使用tcp的方式,不然会丢包很严重
|
||||
// 一直报错的原因!!!就是因为是 2560 * 1440的太大了。。
|
||||
grabber.setImageWidth(imageWid);
|
||||
grabber.setImageHeight(imageHei);
|
||||
System.out.println("grabber start");
|
||||
grabber.start();
|
||||
OpenCVFrameConverter.ToMat converter = new OpenCVFrameConverter.ToMat();
|
||||
OpenCVFrameConverter.ToOrgOpenCvCoreMat converter1 = new OpenCVFrameConverter.ToOrgOpenCvCoreMat();
|
||||
Frame frame = grabber.grabImage();
|
||||
opencv_core.Mat mat = converter.convertToMat(frame);
|
||||
org.opencv.core.Mat cvmat = converter1.convert(converter.convert(mat));
|
||||
//上述的Mat对象
|
||||
Image image = HighGui.toBufferedImage(cvmat);
|
||||
//转换图片
|
||||
BufferedImage bi = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_3BYTE_BGR);
|
||||
Graphics g = bi.getGraphics();
|
||||
g.drawImage(image, 0, 0, null);
|
||||
//将BufferedImage变量写入临时文件中。保存到本地
|
||||
String fileUrl = filePath + CommonUtil.getUUid() + ".jpg";
|
||||
File file = new File(fileUrl);
|
||||
ImageIO.write(bi, "jpg", file);
|
||||
mat.release();
|
||||
cvmat.release();
|
||||
log.info("==========opencv success=============");
|
||||
return fileUrl;
|
||||
} catch (Exception e) {
|
||||
log.info("==========opencv fail=============");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
// /** 摄像头播放 */
|
||||
// public static void play(String rtspURL) throws IOException {
|
||||
// FFmpegFrameGrabber grabber = FFmpegFrameGrabber.createDefault(rtspURL);
|
||||
// grabber.setOption("rtsp_transport", "tcp");
|
||||
// grabber.setImageWidth(960);
|
||||
// grabber.setImageHeight(540);
|
||||
// grabber.start();
|
||||
// CanvasFrame canvasFrame = new CanvasFrame("摄像机");
|
||||
// canvasFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
// canvasFrame.setAlwaysOnTop(true);
|
||||
// OpenCVFrameConverter.ToMat converter = new OpenCVFrameConverter.ToMat();
|
||||
// while (true) {
|
||||
// Frame frame = grabber.grabImage();
|
||||
// opencv_core.Mat mat = converter.convertToMat(frame);
|
||||
// canvasFrame.showImage(frame);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static void screenshot(String rtspURL) throws IOException {
|
||||
// String fileUrl = "D://opencv//" + CommonUtil.getUUid() + ".jpg";
|
||||
// FFmpegFrameGrabber grabber = FFmpegFrameGrabber.createDefault(rtspURL);
|
||||
// grabber.setOption("rtsp_transport", "tcp");
|
||||
// grabber.setImageWidth(960);
|
||||
// grabber.setImageHeight(540);
|
||||
// grabber.start();
|
||||
// File outPut = new File(fileUrl);
|
||||
// while (true) {
|
||||
// Frame frame = grabber.grabImage();
|
||||
// if (frame != null) {
|
||||
// ImageIO.write(FrameToBufferedImage(frame), "jpg", outPut);
|
||||
// grabber.stop();
|
||||
// grabber.release();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 创建BufferedImage对象
|
||||
// */
|
||||
// public static BufferedImage FrameToBufferedImage(Frame frame) {
|
||||
// Java2DFrameConverter converter = new Java2DFrameConverter();
|
||||
// BufferedImage bufferedImage = converter.getBufferedImage(frame);
|
||||
//// bufferedImage=rotateClockwise90(bufferedImage);
|
||||
// return bufferedImage;
|
||||
// }
|
||||
}
|
||||
@ -1,62 +0,0 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.api.image_ai.common;
|
||||
|
||||
import ai.djl.inference.Predictor;
|
||||
import ai.djl.modality.cv.Image;
|
||||
import ai.djl.modality.cv.ImageFactory;
|
||||
import ai.djl.modality.cv.output.BoundingBox;
|
||||
import ai.djl.modality.cv.output.DetectedObjects;
|
||||
import ai.djl.repository.zoo.Criteria;
|
||||
import ai.djl.repository.zoo.ModelZoo;
|
||||
import ai.djl.repository.zoo.ZooModel;
|
||||
import com.zhgd.xmgl.modules.basicdata.api.image_ai.utils.FireSmokeDetect;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 烟火检测例子
|
||||
*
|
||||
* 目录:http://aias.top/
|
||||
*
|
||||
* @author Calvin
|
||||
*/
|
||||
@Slf4j
|
||||
@UtilityClass
|
||||
public final class FireSmokeDetectExample {
|
||||
|
||||
public String imageAi(String imagePath) throws Exception {
|
||||
Path imageFile = Paths.get(imagePath);
|
||||
Image image = ImageFactory.getInstance().fromFile(imageFile);
|
||||
|
||||
Criteria<Image, DetectedObjects> criteria = new FireSmokeDetect().criteria();
|
||||
|
||||
try (ZooModel model = ModelZoo.loadModel(criteria);
|
||||
Predictor<Image, DetectedObjects> predictor = model.newPredictor()) {
|
||||
DetectedObjects detections = predictor.predict(image);
|
||||
List<DetectedObjects.DetectedObject> items = detections.items();
|
||||
|
||||
List<String> names = new ArrayList<>();
|
||||
List<Double> prob = new ArrayList<>();
|
||||
List<BoundingBox> boxes = new ArrayList<>();
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
DetectedObjects.DetectedObject item = items.get(i);
|
||||
if (item.getProbability() < 0.3f) {
|
||||
continue;
|
||||
}
|
||||
names.add(item.getClassName() + " " + item.getProbability());
|
||||
prob.add(item.getProbability());
|
||||
boxes.add(item.getBoundingBox());
|
||||
}
|
||||
|
||||
detections = new DetectedObjects(names, prob, boxes);
|
||||
// ImageUtils.saveBoundingBoxImage(image, detections, "fire_detect_result.png", "build/output");
|
||||
|
||||
log.info("{}", detections);
|
||||
return detections.toJson();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,59 +0,0 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.api.image_ai.common;
|
||||
|
||||
import ai.djl.inference.Predictor;
|
||||
import ai.djl.modality.cv.Image;
|
||||
import ai.djl.modality.cv.ImageFactory;
|
||||
import ai.djl.modality.cv.output.BoundingBox;
|
||||
import ai.djl.modality.cv.output.DetectedObjects;
|
||||
import ai.djl.repository.zoo.Criteria;
|
||||
import ai.djl.repository.zoo.ModelZoo;
|
||||
import ai.djl.repository.zoo.ZooModel;
|
||||
import com.zhgd.xmgl.modules.basicdata.api.image_ai.utils.LargeSafetyHelmetDetect;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 安全帽检测例子
|
||||
*
|
||||
* 目录:http://aias.top/
|
||||
*
|
||||
* @author Calvin
|
||||
*/
|
||||
@Slf4j
|
||||
@UtilityClass
|
||||
public final class LargeSafetyHelmetDetectExample {
|
||||
|
||||
public String imageAi(String imagePath) throws Exception {
|
||||
Path imageFile = Paths.get(imagePath);
|
||||
Image image = ImageFactory.getInstance().fromFile(imageFile);
|
||||
Criteria<Image, DetectedObjects> criteria = new LargeSafetyHelmetDetect().criteria(image);
|
||||
try (ZooModel model = ModelZoo.loadModel(criteria);
|
||||
Predictor<Image, DetectedObjects> predictor = model.newPredictor()) {
|
||||
DetectedObjects detections = predictor.predict(image);
|
||||
List<DetectedObjects.DetectedObject> items = detections.items();
|
||||
|
||||
List<String> names = new ArrayList<>();
|
||||
List<Double> prob = new ArrayList<>();
|
||||
List<BoundingBox> boxes = new ArrayList<>();
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
DetectedObjects.DetectedObject item = items.get(i);
|
||||
if (item.getProbability() < 0.3f) {
|
||||
continue;
|
||||
}
|
||||
names.add(item.getClassName() + " " + item.getProbability());
|
||||
prob.add(item.getProbability());
|
||||
boxes.add(item.getBoundingBox());
|
||||
}
|
||||
|
||||
detections = new DetectedObjects(names, prob, boxes);
|
||||
// ImageUtils.saveBoundingBoxImage(image, detections, "safety_helmet_result_l.png", "build/output");
|
||||
log.info("{}", detections);
|
||||
return detections.toJson();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,62 +0,0 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.api.image_ai.common;
|
||||
|
||||
import ai.djl.inference.Predictor;
|
||||
import ai.djl.modality.cv.Image;
|
||||
import ai.djl.modality.cv.ImageFactory;
|
||||
import ai.djl.modality.cv.output.BoundingBox;
|
||||
import ai.djl.modality.cv.output.DetectedObjects;
|
||||
import ai.djl.repository.zoo.Criteria;
|
||||
import ai.djl.repository.zoo.ModelZoo;
|
||||
import ai.djl.repository.zoo.ZooModel;
|
||||
import com.zhgd.xmgl.modules.basicdata.api.image_ai.utils.MediumSafetyHelmetDetect;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 安全帽检测例子
|
||||
*
|
||||
* 目录:http://aias.top/
|
||||
*
|
||||
* @author Calvin
|
||||
*/
|
||||
@Slf4j
|
||||
@UtilityClass
|
||||
public final class MediumSafetyHelmetDetectExample {
|
||||
|
||||
|
||||
public String imageAi(String imagePath) throws Exception {
|
||||
Path imageFile = Paths.get(imagePath);
|
||||
Image image = ImageFactory.getInstance().fromFile(imageFile);
|
||||
|
||||
Criteria<Image, DetectedObjects> criteria = new MediumSafetyHelmetDetect().criteria(image);
|
||||
|
||||
try (ZooModel model = ModelZoo.loadModel(criteria);
|
||||
Predictor<Image, DetectedObjects> predictor = model.newPredictor()) {
|
||||
DetectedObjects detections = predictor.predict(image);
|
||||
List<DetectedObjects.DetectedObject> items = detections.items();
|
||||
|
||||
List<String> names = new ArrayList<>();
|
||||
List<Double> prob = new ArrayList<>();
|
||||
List<BoundingBox> boxes = new ArrayList<>();
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
DetectedObjects.DetectedObject item = items.get(i);
|
||||
if (item.getProbability() < 0.3f) {
|
||||
continue;
|
||||
}
|
||||
names.add(item.getClassName() + " " + item.getProbability());
|
||||
prob.add(item.getProbability());
|
||||
boxes.add(item.getBoundingBox());
|
||||
}
|
||||
|
||||
detections = new DetectedObjects(names, prob, boxes);
|
||||
// ImageUtils.saveBoundingBoxImage(image, detections, "safety_helmet_result_m.png", "build/output");
|
||||
log.info("{}", detections);
|
||||
return detections.toJson();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,60 +0,0 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.api.image_ai.common;
|
||||
|
||||
import ai.djl.inference.Predictor;
|
||||
import ai.djl.modality.cv.Image;
|
||||
import ai.djl.modality.cv.ImageFactory;
|
||||
import ai.djl.modality.cv.output.BoundingBox;
|
||||
import ai.djl.modality.cv.output.DetectedObjects;
|
||||
import ai.djl.repository.zoo.Criteria;
|
||||
import ai.djl.repository.zoo.ModelZoo;
|
||||
import ai.djl.repository.zoo.ZooModel;
|
||||
import com.zhgd.xmgl.modules.basicdata.api.image_ai.utils.ReflectiveVest;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 行人检测例子 http://aias.top/
|
||||
*
|
||||
* @author Calvin
|
||||
*/
|
||||
@Slf4j
|
||||
@UtilityClass
|
||||
public final class ReflectiveVestDetectExample {
|
||||
|
||||
|
||||
public String imageAi(String imagePath) throws Exception {
|
||||
Path imageFile = Paths.get(imagePath);
|
||||
Image image = ImageFactory.getInstance().fromFile(imageFile);
|
||||
|
||||
Criteria<Image, DetectedObjects> criteria = new ReflectiveVest().criteria();
|
||||
|
||||
try (ZooModel model = ModelZoo.loadModel(criteria);
|
||||
Predictor<Image, DetectedObjects> predictor = model.newPredictor()) {
|
||||
DetectedObjects detections = predictor.predict(image);
|
||||
List<DetectedObjects.DetectedObject> items = detections.items();
|
||||
|
||||
List<String> names = new ArrayList<>();
|
||||
List<Double> prob = new ArrayList<>();
|
||||
List<BoundingBox> boxes = new ArrayList<>();
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
DetectedObjects.DetectedObject item = items.get(i);
|
||||
if (item.getProbability() < 0.5f) {
|
||||
continue;
|
||||
}
|
||||
names.add(item.getClassName() + " " + item.getProbability());
|
||||
prob.add(item.getProbability());
|
||||
boxes.add(item.getBoundingBox());
|
||||
}
|
||||
|
||||
detections = new DetectedObjects(names, prob, boxes);
|
||||
// ImageUtils.saveBoundingBoxImage(image, detections, "reflective_detect_result.png", "build/output");
|
||||
log.info("{}", detections);
|
||||
return detections.toJson();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,61 +0,0 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.api.image_ai.common;
|
||||
|
||||
import ai.djl.inference.Predictor;
|
||||
import ai.djl.modality.cv.Image;
|
||||
import ai.djl.modality.cv.ImageFactory;
|
||||
import ai.djl.modality.cv.output.BoundingBox;
|
||||
import ai.djl.modality.cv.output.DetectedObjects;
|
||||
import ai.djl.repository.zoo.Criteria;
|
||||
import ai.djl.repository.zoo.ModelZoo;
|
||||
import ai.djl.repository.zoo.ZooModel;
|
||||
import com.zhgd.xmgl.modules.basicdata.api.image_ai.utils.SmallSafetyHelmetDetect;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 安全帽检测例子
|
||||
*
|
||||
* 目录:http://aias.top/
|
||||
*
|
||||
* @author Calvin
|
||||
*/
|
||||
@Slf4j
|
||||
@UtilityClass
|
||||
public final class SmallSafetyHelmetDetectExample {
|
||||
|
||||
public String imageAi(String imagePath) throws Exception {
|
||||
Path imageFile = Paths.get(imagePath);
|
||||
Image image = ImageFactory.getInstance().fromFile(imageFile);
|
||||
|
||||
Criteria<Image, DetectedObjects> criteria = new SmallSafetyHelmetDetect().criteria(image);
|
||||
|
||||
try (ZooModel model = ModelZoo.loadModel(criteria);
|
||||
Predictor<Image, DetectedObjects> predictor = model.newPredictor()) {
|
||||
DetectedObjects detections = predictor.predict(image);
|
||||
List<DetectedObjects.DetectedObject> items = detections.items();
|
||||
|
||||
List<String> names = new ArrayList<>();
|
||||
List<Double> prob = new ArrayList<>();
|
||||
List<BoundingBox> boxes = new ArrayList<>();
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
DetectedObjects.DetectedObject item = items.get(i);
|
||||
if (item.getProbability() < 0.3f) {
|
||||
continue;
|
||||
}
|
||||
names.add(item.getClassName() + " " + item.getProbability());
|
||||
prob.add(item.getProbability());
|
||||
boxes.add(item.getBoundingBox());
|
||||
}
|
||||
|
||||
detections = new DetectedObjects(names, prob, boxes);
|
||||
// ImageUtils.saveBoundingBoxImage(image, detections, "safety_helmet_result_s.png", "build/output");
|
||||
log.info("{}", detections);
|
||||
return detections.toJson();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,40 +0,0 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.api.image_ai.utils;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.zhgd.xmgl.modules.basicdata.api.image_ai.Opencv;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@Slf4j
|
||||
@UtilityClass
|
||||
public class AiBroker {
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ApplyAs<T> {
|
||||
|
||||
/**
|
||||
* 执行业务逻辑,返回一个值
|
||||
* @param imagePath
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
String apply(String imagePath) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
public String runAs(String rtsp, ApplyAs<T> func) {
|
||||
try {
|
||||
// 截图
|
||||
String imagePath = Opencv.createImage(rtsp);
|
||||
String result = func.apply(imagePath);
|
||||
// 删图
|
||||
FileUtil.del(new File(imagePath));
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,332 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
||||
* with the License. A copy of the License is located at
|
||||
*
|
||||
* http://aws.amazon.com/apache2.0/
|
||||
*
|
||||
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
|
||||
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
||||
* and limitations under the License.
|
||||
*/
|
||||
package com.zhgd.xmgl.modules.basicdata.api.image_ai.utils;
|
||||
|
||||
import ai.djl.Model;
|
||||
import ai.djl.modality.cv.Image;
|
||||
import ai.djl.modality.cv.transform.CenterCrop;
|
||||
import ai.djl.modality.cv.transform.Normalize;
|
||||
import ai.djl.modality.cv.transform.Resize;
|
||||
import ai.djl.modality.cv.transform.ToTensor;
|
||||
import ai.djl.ndarray.NDArray;
|
||||
import ai.djl.ndarray.NDList;
|
||||
import ai.djl.translate.*;
|
||||
import ai.djl.util.Utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Built-in {@code Translator} that provides default image pre-processing.
|
||||
*
|
||||
* @param <T> the output object type
|
||||
*/
|
||||
public abstract class BaseImageTranslator<T> implements Translator<Image, T> {
|
||||
|
||||
private static final float[] MEAN = {0.485f, 0.456f, 0.406f};
|
||||
private static final float[] STD = {0.229f, 0.224f, 0.225f};
|
||||
|
||||
private Image.Flag flag;
|
||||
private Pipeline pipeline;
|
||||
private Batchifier batchifier;
|
||||
|
||||
/**
|
||||
* Constructs an ImageTranslator with the provided builder.
|
||||
*
|
||||
* @param builder the data to build with
|
||||
*/
|
||||
public BaseImageTranslator(BaseBuilder<?> builder) {
|
||||
flag = builder.flag;
|
||||
pipeline = builder.pipeline;
|
||||
batchifier = builder.batchifier;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Batchifier getBatchifier() {
|
||||
return batchifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the {@link Image} input and converts it to NDList.
|
||||
*
|
||||
* @param ctx the toolkit that helps create the input NDArray
|
||||
* @param input the {@link Image} input
|
||||
* @return a {@link NDList}
|
||||
*/
|
||||
@Override
|
||||
public NDList processInput(TranslatorContext ctx, Image input) {
|
||||
NDArray array = input.toNDArray(ctx.getNDManager(), flag);
|
||||
return pipeline.transform(new NDList(array));
|
||||
}
|
||||
|
||||
protected static String getStringValue(Map<String, ?> arguments, String key, String def) {
|
||||
Object value = arguments.get(key);
|
||||
if (value == null) {
|
||||
return def;
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
protected static int getIntValue(Map<String, ?> arguments, String key, int def) {
|
||||
Object value = arguments.get(key);
|
||||
if (value == null) {
|
||||
return def;
|
||||
}
|
||||
return (int) Double.parseDouble(value.toString());
|
||||
}
|
||||
|
||||
protected static float getFloatValue(Map<String, ?> arguments, String key, float def) {
|
||||
Object value = arguments.get(key);
|
||||
if (value == null) {
|
||||
return def;
|
||||
}
|
||||
return (float) Double.parseDouble(value.toString());
|
||||
}
|
||||
|
||||
protected static boolean getBooleanValue(Map<String, ?> arguments, String key, boolean def) {
|
||||
Object value = arguments.get(key);
|
||||
if (value == null) {
|
||||
return def;
|
||||
}
|
||||
return Boolean.parseBoolean(value.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder to extend for all classes extending the {@link BaseImageTranslator}.
|
||||
*
|
||||
* @param <T> the concrete builder type
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract static class BaseBuilder<T extends BaseBuilder> {
|
||||
|
||||
protected int width = 224;
|
||||
protected int height = 224;
|
||||
protected Image.Flag flag = Image.Flag.COLOR;
|
||||
protected Pipeline pipeline;
|
||||
protected Batchifier batchifier = Batchifier.STACK;
|
||||
|
||||
/**
|
||||
* Sets the optional {@link Image.Flag} (default is {@link
|
||||
* Image.Flag#COLOR}).
|
||||
*
|
||||
* @param flag the color mode for the images
|
||||
* @return this builder
|
||||
*/
|
||||
public T optFlag(Image.Flag flag) {
|
||||
this.flag = flag;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link Pipeline} to use for pre-processing the image.
|
||||
*
|
||||
* @param pipeline the pre-processing pipeline
|
||||
* @return this builder
|
||||
*/
|
||||
public T setPipeline(Pipeline pipeline) {
|
||||
this.pipeline = pipeline;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the {@link Transform} to the {@link Pipeline} use for pre-processing the image.
|
||||
*
|
||||
* @param transform the {@link Transform} to be added
|
||||
* @return this builder
|
||||
*/
|
||||
public T addTransform(Transform transform) {
|
||||
if (pipeline == null) {
|
||||
pipeline = new Pipeline();
|
||||
}
|
||||
pipeline.add(transform);
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link Batchifier} for the {@link Translator}.
|
||||
*
|
||||
* @param batchifier the {@link Batchifier} to be set
|
||||
* @return this builder
|
||||
*/
|
||||
public T optBatchifier(Batchifier batchifier) {
|
||||
this.batchifier = batchifier;
|
||||
return self();
|
||||
}
|
||||
|
||||
protected abstract T self();
|
||||
|
||||
protected void validate() {
|
||||
if (pipeline == null) {
|
||||
throw new IllegalArgumentException("pipeline is required.");
|
||||
}
|
||||
}
|
||||
|
||||
protected void configPreProcess(Map<String, ?> arguments) {
|
||||
if (pipeline == null) {
|
||||
pipeline = new Pipeline();
|
||||
}
|
||||
width = getIntValue(arguments, "width", 224);
|
||||
height = getIntValue(arguments, "height", 224);
|
||||
if (arguments.containsKey("flag")) {
|
||||
flag = Image.Flag.valueOf(arguments.get("flag").toString());
|
||||
}
|
||||
if (getBooleanValue(arguments, "centerCrop", false)) {
|
||||
addTransform(new CenterCrop());
|
||||
}
|
||||
if (getBooleanValue(arguments, "resize", false)) {
|
||||
addTransform(new Resize(width, height));
|
||||
}
|
||||
if (getBooleanValue(arguments, "toTensor", true)) {
|
||||
addTransform(new ToTensor());
|
||||
}
|
||||
String normalize = getStringValue(arguments, "normalize", "false");
|
||||
if ("true".equals(normalize)) {
|
||||
addTransform(new Normalize(MEAN, STD));
|
||||
} else if (!"false".equals(normalize)) {
|
||||
String[] tokens = normalize.split("\\s*,\\s*");
|
||||
if (tokens.length != 6) {
|
||||
throw new IllegalArgumentException("Invalid normalize value: " + normalize);
|
||||
}
|
||||
float[] mean = {
|
||||
Float.parseFloat(tokens[0]),
|
||||
Float.parseFloat(tokens[1]),
|
||||
Float.parseFloat(tokens[2])
|
||||
};
|
||||
float[] std = {
|
||||
Float.parseFloat(tokens[3]),
|
||||
Float.parseFloat(tokens[4]),
|
||||
Float.parseFloat(tokens[5])
|
||||
};
|
||||
addTransform(new Normalize(mean, std));
|
||||
}
|
||||
String range = (String) arguments.get("range");
|
||||
if ("0,1".equals(range)) {
|
||||
addTransform(a -> a.div(255f));
|
||||
} else if ("-1,1".equals(range)) {
|
||||
addTransform(a -> a.div(128f).sub(1));
|
||||
}
|
||||
if (arguments.containsKey("batchifier")) {
|
||||
batchifier = Batchifier.fromString((String) arguments.get("batchifier"));
|
||||
}
|
||||
}
|
||||
|
||||
protected void configPostProcess(Map<String, ?> arguments) {}
|
||||
}
|
||||
|
||||
/** A Builder to construct a {@code ImageClassificationTranslator}. */
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract static class ClassificationBuilder<T extends BaseBuilder>
|
||||
extends BaseBuilder<T> {
|
||||
|
||||
protected SynsetLoader synsetLoader;
|
||||
|
||||
/**
|
||||
* Sets the name of the synset file listing the potential classes for an image.
|
||||
*
|
||||
* @param synsetArtifactName a file listing the potential classes for an image
|
||||
* @return the builder
|
||||
*/
|
||||
public T optSynsetArtifactName(String synsetArtifactName) {
|
||||
synsetLoader = new SynsetLoader(synsetArtifactName);
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the URL of the synset file.
|
||||
*
|
||||
* @param synsetUrl the URL of the synset file
|
||||
* @return the builder
|
||||
*/
|
||||
public T optSynsetUrl(String synsetUrl) {
|
||||
try {
|
||||
this.synsetLoader = new SynsetLoader(new URL(synsetUrl));
|
||||
} catch (MalformedURLException e) {
|
||||
throw new IllegalArgumentException("Invalid synsetUrl: " + synsetUrl, e);
|
||||
}
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the potential classes for an image.
|
||||
*
|
||||
* @param synset the potential classes for an image
|
||||
* @return the builder
|
||||
*/
|
||||
public T optSynset(List<String> synset) {
|
||||
synsetLoader = new SynsetLoader(synset);
|
||||
return self();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void validate() {
|
||||
super.validate();
|
||||
if (synsetLoader == null) {
|
||||
synsetLoader = new SynsetLoader("synset.txt");
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void configPostProcess(Map<String, ?> arguments) {
|
||||
String synset = (String) arguments.get("synset");
|
||||
if (synset != null) {
|
||||
optSynset(Arrays.asList(synset.split(",")));
|
||||
}
|
||||
String synsetUrl = (String) arguments.get("synsetUrl");
|
||||
if (synsetUrl != null) {
|
||||
optSynsetUrl(synsetUrl);
|
||||
}
|
||||
String synsetFileName = (String) arguments.get("synsetFileName");
|
||||
if (synsetFileName != null) {
|
||||
optSynsetArtifactName(synsetFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static final class SynsetLoader {
|
||||
|
||||
private String synsetFileName;
|
||||
private URL synsetUrl;
|
||||
private List<String> synset;
|
||||
|
||||
public SynsetLoader(List<String> synset) {
|
||||
this.synset = synset;
|
||||
}
|
||||
|
||||
public SynsetLoader(URL synsetUrl) {
|
||||
this.synsetUrl = synsetUrl;
|
||||
}
|
||||
|
||||
public SynsetLoader(String synsetFileName) {
|
||||
this.synsetFileName = synsetFileName;
|
||||
}
|
||||
|
||||
public List<String> load(Model model) throws IOException {
|
||||
if (synset != null) {
|
||||
return synset;
|
||||
} else if (synsetUrl != null) {
|
||||
try (InputStream is = synsetUrl.openStream()) {
|
||||
return Utils.readLines(is);
|
||||
}
|
||||
}
|
||||
return model.getArtifact(synsetFileName, Utils::readLines);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,50 +0,0 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.api.image_ai.utils;
|
||||
|
||||
import ai.djl.Device;
|
||||
import ai.djl.modality.cv.Image;
|
||||
import ai.djl.modality.cv.output.DetectedObjects;
|
||||
import ai.djl.modality.cv.translator.YoloV5Translator;
|
||||
import ai.djl.repository.zoo.Criteria;
|
||||
import ai.djl.training.util.ProgressBar;
|
||||
import ai.djl.translate.Translator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/** 烟火检测 https://github.com/gengyanlei/fire-smoke-detect-yolov4 */
|
||||
public final class FireSmokeDetect {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(FireSmokeDetect.class);
|
||||
|
||||
public FireSmokeDetect() {}
|
||||
|
||||
public Criteria<Image, DetectedObjects> criteria() {
|
||||
Map<String, Object> arguments = new ConcurrentHashMap<>();
|
||||
arguments.put("width", 640);
|
||||
arguments.put("height", 640);
|
||||
arguments.put("resize", true);
|
||||
arguments.put("rescale", true);
|
||||
// arguments.put("toTensor", false);
|
||||
// arguments.put("range", "0,1");
|
||||
// arguments.put("normalize", "false");
|
||||
arguments.put("threshold", 0.2);
|
||||
arguments.put("nmsThreshold", 0.5);
|
||||
|
||||
Translator<Image, DetectedObjects> translator = YoloV5Translator.builder(arguments).build();
|
||||
|
||||
Criteria<Image, DetectedObjects> criteria =
|
||||
Criteria.builder()
|
||||
.setTypes(Image.class, DetectedObjects.class)
|
||||
.optModelUrls("https://aias-home.oss-cn-beijing.aliyuncs.com/models/fire_smoke.zip")
|
||||
// .optModelUrls("/Users/calvin/Documents/build/pytorch_models/fire_smoke/")
|
||||
.optTranslator(translator)
|
||||
.optProgress(new ProgressBar())
|
||||
.optEngine("PyTorch")
|
||||
.optDevice(Device.cpu())
|
||||
.build();
|
||||
|
||||
return criteria;
|
||||
}
|
||||
}
|
||||
@ -1,197 +0,0 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.api.image_ai.utils;
|
||||
|
||||
import ai.djl.modality.cv.Image;
|
||||
import ai.djl.modality.cv.ImageFactory;
|
||||
import ai.djl.modality.cv.output.BoundingBox;
|
||||
import ai.djl.modality.cv.output.DetectedObjects;
|
||||
import ai.djl.modality.cv.output.Rectangle;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class ImageUtils {
|
||||
|
||||
/**
|
||||
* BufferedImage图片格式转DJL图片格式
|
||||
*
|
||||
* @author Calvin
|
||||
*/
|
||||
public static Image convert(BufferedImage img) {
|
||||
return ImageFactory.getInstance().fromImage(img);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存BufferedImage图片
|
||||
*
|
||||
* @author Calvin
|
||||
*/
|
||||
public static void saveImage(BufferedImage img, String name, String path) {
|
||||
Image djlImg = ImageFactory.getInstance().fromImage(img); // 支持多种图片格式,自动适配
|
||||
Path outputDir = Paths.get(path);
|
||||
Path imagePath = outputDir.resolve(name);
|
||||
// OpenJDK 不能保存 jpg 图片的 alpha channel
|
||||
try {
|
||||
djlImg.save(Files.newOutputStream(imagePath), "png");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存DJL图片
|
||||
*
|
||||
* @author Calvin
|
||||
*/
|
||||
public static void saveImage(Image img, String name, String path) {
|
||||
Path outputDir = Paths.get(path);
|
||||
Path imagePath = outputDir.resolve(name);
|
||||
// OpenJDK 不能保存 jpg 图片的 alpha channel
|
||||
try {
|
||||
img.save(Files.newOutputStream(imagePath), "png");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存图片,含检测框
|
||||
*
|
||||
* @author Calvin
|
||||
*/
|
||||
public static void saveBoundingBoxImage(
|
||||
Image img, DetectedObjects detection, String name, String path) throws IOException {
|
||||
// Make image copy with alpha channel because original image was jpg
|
||||
img.drawBoundingBoxes(detection);
|
||||
Path outputDir = Paths.get(path);
|
||||
Files.createDirectories(outputDir);
|
||||
Path imagePath = outputDir.resolve(name);
|
||||
// OpenJDK can't save jpg with alpha channel
|
||||
img.save(Files.newOutputStream(imagePath), "png");
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制人脸关键点
|
||||
*
|
||||
* @author Calvin
|
||||
*/
|
||||
public static void drawLandmark(Image img, BoundingBox box, float[] array) {
|
||||
for (int i = 0; i < array.length / 2; i++) {
|
||||
int x = getX(img, box, array[2 * i]);
|
||||
int y = getY(img, box, array[2 * i + 1]);
|
||||
Color c = new Color(0, 255, 0);
|
||||
drawImageRect((BufferedImage) img.getWrappedImage(), x, y, 1, 1, c);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 画检测框
|
||||
*
|
||||
* @author Calvin
|
||||
*/
|
||||
public static void drawImageRect(BufferedImage image, int x, int y, int width, int height) {
|
||||
// 将绘制图像转换为Graphics2D
|
||||
Graphics2D g = (Graphics2D) image.getGraphics();
|
||||
try {
|
||||
g.setColor(new Color(246, 96, 0));
|
||||
// 声明画笔属性 :粗 细(单位像素)末端无修饰 折线处呈尖角
|
||||
BasicStroke bStroke = new BasicStroke(4, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);
|
||||
g.setStroke(bStroke);
|
||||
g.drawRect(x, y, width, height);
|
||||
|
||||
} finally {
|
||||
g.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 画检测框
|
||||
*
|
||||
* @author Calvin
|
||||
*/
|
||||
public static void drawImageRect(
|
||||
BufferedImage image, int x, int y, int width, int height, Color c) {
|
||||
// 将绘制图像转换为Graphics2D
|
||||
Graphics2D g = (Graphics2D) image.getGraphics();
|
||||
try {
|
||||
g.setColor(c);
|
||||
// 声明画笔属性 :粗 细(单位像素)末端无修饰 折线处呈尖角
|
||||
BasicStroke bStroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);
|
||||
g.setStroke(bStroke);
|
||||
g.drawRect(x, y, width, height);
|
||||
|
||||
} finally {
|
||||
g.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示文字
|
||||
*
|
||||
* @author Calvin
|
||||
*/
|
||||
public static void drawImageText(BufferedImage image, String text) {
|
||||
Graphics graphics = image.getGraphics();
|
||||
int fontSize = 100;
|
||||
Font font = new Font("楷体", Font.PLAIN, fontSize);
|
||||
try {
|
||||
graphics.setFont(font);
|
||||
graphics.setColor(new Color(246, 96, 0));
|
||||
int strWidth = graphics.getFontMetrics().stringWidth(text);
|
||||
graphics.drawString(text, fontSize - (strWidth / 2), fontSize + 30);
|
||||
} finally {
|
||||
graphics.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回外扩人脸 factor = 1, 100%, factor = 0.2, 20%
|
||||
*
|
||||
* @author Calvin
|
||||
*/
|
||||
public static Image getSubImage(Image img, BoundingBox box, float factor) {
|
||||
Rectangle rect = box.getBounds();
|
||||
// 左上角坐标
|
||||
int x1 = (int) (rect.getX() * img.getWidth());
|
||||
int y1 = (int) (rect.getY() * img.getHeight());
|
||||
// 宽度,高度
|
||||
int w = (int) (rect.getWidth() * img.getWidth());
|
||||
int h = (int) (rect.getHeight() * img.getHeight());
|
||||
// 左上角坐标
|
||||
int x2 = x1 + w;
|
||||
int y2 = y1 + h;
|
||||
|
||||
// 外扩大100%,防止对齐后人脸出现黑边
|
||||
int new_x1 = Math.max((int) (x1 + x1 * factor / 2 - x2 * factor / 2), 0);
|
||||
int new_x2 = Math.min((int) (x2 + x2 * factor / 2 - x1 * factor / 2), img.getWidth() - 1);
|
||||
int new_y1 = Math.max((int) (y1 + y1 * factor / 2 - y2 * factor / 2), 0);
|
||||
int new_y2 = Math.min((int) (y2 + y2 * factor / 2 - y1 * factor / 2), img.getHeight() - 1);
|
||||
int new_w = new_x2 - new_x1;
|
||||
int new_h = new_y2 - new_y1;
|
||||
|
||||
return img.getSubImage(new_x1, new_y1, new_w, new_h);
|
||||
}
|
||||
|
||||
private static int getX(Image img, BoundingBox box, float x) {
|
||||
Rectangle rect = box.getBounds();
|
||||
// 左上角坐标
|
||||
int x1 = (int) (rect.getX() * img.getWidth());
|
||||
// 宽度
|
||||
int w = (int) (rect.getWidth() * img.getWidth());
|
||||
|
||||
return (int) (x * w + x1);
|
||||
}
|
||||
|
||||
private static int getY(Image img, BoundingBox box, float y) {
|
||||
Rectangle rect = box.getBounds();
|
||||
// 左上角坐标
|
||||
int y1 = (int) (rect.getY() * img.getHeight());
|
||||
// 高度
|
||||
int h = (int) (rect.getHeight() * img.getHeight());
|
||||
|
||||
return (int) (y * h + y1);
|
||||
}
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.api.image_ai.utils;
|
||||
|
||||
import ai.djl.modality.cv.Image;
|
||||
import ai.djl.modality.cv.output.DetectedObjects;
|
||||
import ai.djl.repository.zoo.Criteria;
|
||||
import ai.djl.training.util.ProgressBar;
|
||||
import ai.djl.translate.Translator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 安全帽检测
|
||||
* https://github.com/njvisionpower/Safety-Helmet-Wearing-Dataset
|
||||
*/
|
||||
|
||||
public final class LargeSafetyHelmetDetect {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(LargeSafetyHelmetDetect.class);
|
||||
|
||||
public LargeSafetyHelmetDetect() {}
|
||||
|
||||
public Criteria<Image, DetectedObjects> criteria(Image image) {
|
||||
Map<String, Object> arguments = new ConcurrentHashMap<>();
|
||||
int[] size = scale(image.getHeight(), image.getWidth());
|
||||
arguments.put("width", size[1]);
|
||||
arguments.put("height", size[0]);
|
||||
arguments.put("resize", true);
|
||||
arguments.put("rescale", true);
|
||||
arguments.put("normalize", true);
|
||||
arguments.put("threshold", 0.2);
|
||||
|
||||
Translator<Image, DetectedObjects> translator = YoloTranslator.builder(arguments).build();
|
||||
|
||||
Criteria<Image, DetectedObjects> criteria =
|
||||
Criteria.builder()
|
||||
.setTypes(Image.class, DetectedObjects.class)
|
||||
.optModelUrls("https://aias-home.oss-cn-beijing.aliyuncs.com/models/sec_models/darknet53.zip")
|
||||
// .optModelUrls("/Users/calvin/Desktop/Download/browser/Safety-Helmet-Wearing-Dataset-master/symbol/darknet53/")
|
||||
.optTranslator(translator)
|
||||
.optProgress(new ProgressBar())
|
||||
.optEngine("MXNet")
|
||||
.build();
|
||||
|
||||
return criteria;
|
||||
}
|
||||
|
||||
private static int[] scale(int h, int w) {
|
||||
int min = Math.min(h, w);
|
||||
float scale = 1.0F;
|
||||
|
||||
scale = (float) 416 * 1.0F / (float) min;
|
||||
|
||||
return new int[] {(int) ((float) h * scale), (int) ((float) w * scale)};
|
||||
}
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.api.image_ai.utils;
|
||||
|
||||
import ai.djl.modality.cv.Image;
|
||||
import ai.djl.modality.cv.output.DetectedObjects;
|
||||
import ai.djl.repository.zoo.Criteria;
|
||||
import ai.djl.training.util.ProgressBar;
|
||||
import ai.djl.translate.Translator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 安全帽检测
|
||||
* https://github.com/njvisionpower/Safety-Helmet-Wearing-Dataset
|
||||
*/
|
||||
|
||||
public final class MediumSafetyHelmetDetect {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MediumSafetyHelmetDetect.class);
|
||||
|
||||
public MediumSafetyHelmetDetect() {}
|
||||
|
||||
public Criteria<Image, DetectedObjects> criteria(Image image) {
|
||||
Map<String, Object> arguments = new ConcurrentHashMap<>();
|
||||
int[] size = scale(image.getHeight(), image.getWidth());
|
||||
arguments.put("width", size[1]);
|
||||
arguments.put("height", size[0]);
|
||||
arguments.put("resize", true);
|
||||
arguments.put("rescale", true);
|
||||
arguments.put("normalize", true);
|
||||
arguments.put("threshold", 0.2);
|
||||
|
||||
Translator<Image, DetectedObjects> translator = YoloTranslator.builder(arguments).build();
|
||||
|
||||
Criteria<Image, DetectedObjects> criteria =
|
||||
Criteria.builder()
|
||||
.setTypes(Image.class, DetectedObjects.class)
|
||||
.optModelUrls("https://aias-home.oss-cn-beijing.aliyuncs.com/models/sec_models/mobilenet1.0.zip")
|
||||
// .optModelUrls("/Users/calvin/Desktop/Download/browser/Safety-Helmet-Wearing-Dataset-master/symbol/darknet53/")
|
||||
.optTranslator(translator)
|
||||
.optProgress(new ProgressBar())
|
||||
.optEngine("MXNet")
|
||||
.build();
|
||||
|
||||
return criteria;
|
||||
}
|
||||
|
||||
private static int[] scale(int h, int w) {
|
||||
int min = Math.min(h, w);
|
||||
float scale = 1.0F;
|
||||
|
||||
scale = (float) 416 * 1.0F / (float) min;
|
||||
|
||||
return new int[] {(int) ((float) h * scale), (int) ((float) w * scale)};
|
||||
}
|
||||
}
|
||||
@ -1,121 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
||||
* with the License. A copy of the License is located at
|
||||
*
|
||||
* http://aws.amazon.com/apache2.0/
|
||||
*
|
||||
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
|
||||
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
||||
* and limitations under the License.
|
||||
*/
|
||||
package com.zhgd.xmgl.modules.basicdata.api.image_ai.utils;
|
||||
|
||||
import ai.djl.Model;
|
||||
import ai.djl.modality.cv.output.DetectedObjects;
|
||||
import ai.djl.ndarray.NDArray;
|
||||
import ai.djl.translate.TranslatorContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A {@link BaseImageTranslator} that post-process the {@link NDArray} into {@link DetectedObjects}
|
||||
* with boundaries.
|
||||
*/
|
||||
public abstract class ObjectDetectionTranslator extends BaseImageTranslator<DetectedObjects> {
|
||||
|
||||
protected float threshold;
|
||||
private SynsetLoader synsetLoader;
|
||||
protected List<String> classes;
|
||||
protected double imageWidth;
|
||||
protected double imageHeight;
|
||||
|
||||
/**
|
||||
* Creates the {@link ObjectDetectionTranslator} from the given builder.
|
||||
*
|
||||
* @param builder the builder for the translator
|
||||
*/
|
||||
protected ObjectDetectionTranslator(ObjectDetectionBuilder<?> builder) {
|
||||
super(builder);
|
||||
this.threshold = builder.threshold;
|
||||
this.synsetLoader = builder.synsetLoader;
|
||||
this.imageWidth = builder.imageWidth;
|
||||
this.imageHeight = builder.imageHeight;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void prepare(TranslatorContext ctx) throws IOException {
|
||||
Model model = ctx.getModel();
|
||||
if (classes == null) {
|
||||
classes = synsetLoader.load(model);
|
||||
}
|
||||
}
|
||||
|
||||
/** The base builder for the object detection translator. */
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract static class ObjectDetectionBuilder<T extends ObjectDetectionBuilder>
|
||||
extends ClassificationBuilder<T> {
|
||||
|
||||
protected float threshold = 0.2f;
|
||||
protected double imageWidth;
|
||||
protected double imageHeight;
|
||||
|
||||
/**
|
||||
* Sets the threshold for prediction accuracy.
|
||||
*
|
||||
* <p>Predictions below the threshold will be dropped.
|
||||
*
|
||||
* @param threshold the threshold for the prediction accuracy
|
||||
* @return this builder
|
||||
*/
|
||||
public T optThreshold(float threshold) {
|
||||
this.threshold = threshold;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the optional rescale size.
|
||||
*
|
||||
* @param imageWidth the width to rescale images to
|
||||
* @param imageHeight the height to rescale images to
|
||||
* @return this builder
|
||||
*/
|
||||
public T optRescaleSize(double imageWidth, double imageHeight) {
|
||||
this.imageWidth = imageWidth;
|
||||
this.imageHeight = imageHeight;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resized image width.
|
||||
*
|
||||
* @return image width
|
||||
*/
|
||||
public double getImageWidth() {
|
||||
return imageWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resized image height.
|
||||
*
|
||||
* @return image height
|
||||
*/
|
||||
public double getImageHeight() {
|
||||
return imageHeight;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void configPostProcess(Map<String, ?> arguments) {
|
||||
super.configPostProcess(arguments);
|
||||
if (getBooleanValue(arguments, "rescale", false)) {
|
||||
optRescaleSize(width, height);
|
||||
}
|
||||
threshold = getFloatValue(arguments, "threshold", 0.2f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,51 +0,0 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.api.image_ai.utils;
|
||||
|
||||
import ai.djl.Device;
|
||||
import ai.djl.modality.cv.Image;
|
||||
import ai.djl.modality.cv.output.DetectedObjects;
|
||||
import ai.djl.modality.cv.translator.YoloV5Translator;
|
||||
import ai.djl.repository.zoo.Criteria;
|
||||
import ai.djl.training.util.ProgressBar;
|
||||
import ai.djl.translate.Translator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/** https://github.com/gengyanlei/reflective-clothes-detect-yolov5/blob/master/README_ZN.md */
|
||||
public final class ReflectiveVest {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ReflectiveVest.class);
|
||||
|
||||
public ReflectiveVest() {}
|
||||
|
||||
public Criteria<Image, DetectedObjects> criteria() {
|
||||
Map<String, Object> arguments = new ConcurrentHashMap<>();
|
||||
arguments.put("width", 640);
|
||||
arguments.put("height", 640);
|
||||
arguments.put("resize", true);
|
||||
arguments.put("rescale", true);
|
||||
// arguments.put("toTensor", false);
|
||||
// arguments.put("range", "0,1");
|
||||
// arguments.put("normalize", "false");
|
||||
arguments.put("threshold", 0.2);
|
||||
arguments.put("nmsThreshold", 0.5);
|
||||
|
||||
Translator<Image, DetectedObjects> translator = YoloV5Translator.builder(arguments).build();
|
||||
|
||||
Criteria<Image, DetectedObjects> criteria =
|
||||
Criteria.builder()
|
||||
.setTypes(Image.class, DetectedObjects.class)
|
||||
.optModelUrls(
|
||||
"https://aias-home.oss-cn-beijing.aliyuncs.com/models/reflective_clothes.zip")
|
||||
// .optModelUrls("/Users/calvin/Documents/build/pytorch_models/reflective_clothes/")
|
||||
.optTranslator(translator)
|
||||
.optProgress(new ProgressBar())
|
||||
.optEngine("PyTorch")
|
||||
.optDevice(Device.cpu())
|
||||
.build();
|
||||
|
||||
return criteria;
|
||||
}
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.api.image_ai.utils;
|
||||
|
||||
import ai.djl.modality.cv.Image;
|
||||
import ai.djl.modality.cv.output.DetectedObjects;
|
||||
import ai.djl.repository.zoo.Criteria;
|
||||
import ai.djl.training.util.ProgressBar;
|
||||
import ai.djl.translate.Translator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 安全帽检测
|
||||
* https://github.com/njvisionpower/Safety-Helmet-Wearing-Dataset
|
||||
*/
|
||||
|
||||
public final class SmallSafetyHelmetDetect {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SmallSafetyHelmetDetect.class);
|
||||
|
||||
public SmallSafetyHelmetDetect() {}
|
||||
|
||||
public Criteria<Image, DetectedObjects> criteria(Image image) {
|
||||
Map<String, Object> arguments = new ConcurrentHashMap<>();
|
||||
int[] size = scale(image.getHeight(), image.getWidth());
|
||||
arguments.put("width", size[1]);
|
||||
arguments.put("height", size[0]);
|
||||
arguments.put("resize", true);
|
||||
arguments.put("rescale", true);
|
||||
arguments.put("normalize", true);
|
||||
arguments.put("threshold", 0.2);
|
||||
|
||||
Translator<Image, DetectedObjects> translator = YoloTranslator.builder(arguments).build();
|
||||
|
||||
Criteria<Image, DetectedObjects> criteria =
|
||||
Criteria.builder()
|
||||
.setTypes(Image.class, DetectedObjects.class)
|
||||
.optModelUrls("https://aias-home.oss-cn-beijing.aliyuncs.com/models/sec_models/mobilenet0.25.zip")
|
||||
// .optModelUrls("/Users/calvin/Desktop/Download/browser/Safety-Helmet-Wearing-Dataset-master/symbol/darknet53/")
|
||||
.optTranslator(translator)
|
||||
.optProgress(new ProgressBar())
|
||||
.optEngine("MXNet")
|
||||
.build();
|
||||
|
||||
return criteria;
|
||||
}
|
||||
|
||||
private static int[] scale(int h, int w) {
|
||||
int min = Math.min(h, w);
|
||||
float scale = 1.0F;
|
||||
|
||||
scale = (float) 416 * 1.0F / (float) min;
|
||||
|
||||
return new int[] {(int) ((float) h * scale), (int) ((float) w * scale)};
|
||||
}
|
||||
}
|
||||
@ -1,114 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
|
||||
* with the License. A copy of the License is located at
|
||||
*
|
||||
* http://aws.amazon.com/apache2.0/
|
||||
*
|
||||
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
|
||||
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
||||
* and limitations under the License.
|
||||
*/
|
||||
package com.zhgd.xmgl.modules.basicdata.api.image_ai.utils;
|
||||
|
||||
import ai.djl.modality.cv.output.BoundingBox;
|
||||
import ai.djl.modality.cv.output.DetectedObjects;
|
||||
import ai.djl.modality.cv.output.Rectangle;
|
||||
import ai.djl.ndarray.NDArray;
|
||||
import ai.djl.ndarray.NDList;
|
||||
import ai.djl.ndarray.types.DataType;
|
||||
import ai.djl.translate.TranslatorContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/** A translator for yolo models. */
|
||||
public class YoloTranslator extends ObjectDetectionTranslator {
|
||||
|
||||
/**
|
||||
* Constructs an ImageTranslator with the provided builder.
|
||||
*
|
||||
* @param builder the data to build with
|
||||
*/
|
||||
public YoloTranslator(Builder builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public DetectedObjects processOutput(TranslatorContext ctx, NDList list) {
|
||||
int[] classIndices = list.get(0).toType(DataType.INT32, true).flatten().toIntArray();
|
||||
double[] probs = list.get(1).toType(DataType.FLOAT64, true).flatten().toDoubleArray();
|
||||
NDArray boundingBoxes = list.get(2);
|
||||
int detected = Math.toIntExact(probs.length);
|
||||
|
||||
NDArray xMin = boundingBoxes.get(":, 0").clip(0, imageWidth).div(imageWidth);
|
||||
NDArray yMin = boundingBoxes.get(":, 1").clip(0, imageHeight).div(imageHeight);
|
||||
NDArray xMax = boundingBoxes.get(":, 2").clip(0, imageWidth).div(imageWidth);
|
||||
NDArray yMax = boundingBoxes.get(":, 3").clip(0, imageHeight).div(imageHeight);
|
||||
|
||||
float[] boxX = xMin.toFloatArray();
|
||||
float[] boxY = yMin.toFloatArray();
|
||||
float[] boxWidth = xMax.sub(xMin).toFloatArray();
|
||||
float[] boxHeight = yMax.sub(yMin).toFloatArray();
|
||||
|
||||
List<String> retClasses = new ArrayList<>(detected);
|
||||
List<Double> retProbs = new ArrayList<>(detected);
|
||||
List<BoundingBox> retBB = new ArrayList<>(detected);
|
||||
for (int i = 0; i < detected; i++) {
|
||||
if (classIndices[i] < 0 || probs[i] < threshold) {
|
||||
continue;
|
||||
}
|
||||
retClasses.add(classes.get(classIndices[i]));
|
||||
retProbs.add(probs[i]);
|
||||
Rectangle rect = new Rectangle(boxX[i], boxY[i], boxWidth[i], boxHeight[i]);
|
||||
retBB.add(rect);
|
||||
}
|
||||
return new DetectedObjects(retClasses, retProbs, retBB);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a builder to build a {@link YoloTranslator}.
|
||||
*
|
||||
* @return a new builder
|
||||
*/
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a builder to build a {@code YoloTranslator} with specified arguments.
|
||||
*
|
||||
* @param arguments arguments to specify builder options
|
||||
* @return a new builder
|
||||
*/
|
||||
public static Builder builder(Map<String, ?> arguments) {
|
||||
Builder builder = new Builder();
|
||||
builder.configPreProcess(arguments);
|
||||
builder.configPostProcess(arguments);
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
/** The builder for {@link YoloTranslator}. */
|
||||
public static class Builder extends ObjectDetectionBuilder<Builder> {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected Builder self() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the translator.
|
||||
*
|
||||
* @return the new translator
|
||||
*/
|
||||
public YoloTranslator build() {
|
||||
validate();
|
||||
return new YoloTranslator(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -149,6 +149,12 @@ public class GovernmentController {
|
||||
if(governmentEntity==null) {
|
||||
result.error500("未找到对应实体");
|
||||
}else {
|
||||
// 检验政务账号是否已存在
|
||||
SystemUser systemUser = systemUserService.getOne(Wrappers.<SystemUser>lambdaQuery().eq(SystemUser::getAccount, governmentVo.getAccount()));
|
||||
if (systemUser != null) {
|
||||
result.error500("该用户账号已被使用");
|
||||
return result;
|
||||
}
|
||||
boolean ok = governmentService.updateInfo(governmentVo) == 1 ? true : false;
|
||||
if(ok) {
|
||||
result.success("修改成功!");
|
||||
|
||||
@ -78,8 +78,8 @@ public class SystemUserAuthController {
|
||||
public Result<SystemUserAuthDto> login(@ApiIgnore @RequestBody SystemUser systemUser) {
|
||||
Result<SystemUserAuthDto> result = new Result<SystemUserAuthDto>();
|
||||
SystemUser user = systemUserService.getOne(Wrappers.<SystemUser>lambdaQuery()
|
||||
.eq(SystemUser::getAccount, systemUser.getAccount())
|
||||
.eq(SystemUser::getShowPassword, systemUser.getShowPassword()));
|
||||
.eq(SystemUser::getAccount, Aes.decrypt(systemUser.getAccount()))
|
||||
.eq(SystemUser::getShowPassword, Aes.decrypt(systemUser.getShowPassword())));
|
||||
SystemUserAuthDto userInfo = new SystemUserAuthDto();
|
||||
checkLogin(user, userInfo, result);
|
||||
if (result.getCode() != CommonConstant.SC_INTERNAL_SERVER_ERROR_500) {
|
||||
|
||||
@ -8,6 +8,7 @@ import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.IEnterpriseService;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
|
||||
import com.zhgd.xmgl.modules.basicdata.vo.EnterpriseVo;
|
||||
import com.zhgd.xmgl.util.CommonUtil;
|
||||
import com.zhgd.xmgl.valid.AddGroup;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@ -51,6 +52,10 @@ public class EntEnterpriseController {
|
||||
@PostMapping(value = "/add")
|
||||
public Result<Enterprise> add(@RequestBody @Validated(AddGroup.class) EnterpriseVo enterpriseVo) {
|
||||
Result<Enterprise> result = new Result<Enterprise>();
|
||||
if (!CommonUtil.checkStrongPwd(enterpriseVo.getPassword())) {
|
||||
result.error500("密码必须包含数字、大小写字母、特殊符号且大于8位");
|
||||
return result;
|
||||
}
|
||||
// 检验企业账号是否已存在
|
||||
SystemUser systemUser = systemUserService.getOne(Wrappers.<SystemUser>lambdaQuery().eq(SystemUser::getAccount, enterpriseVo.getAccount()));
|
||||
if (systemUser != null) {
|
||||
|
||||
@ -81,6 +81,7 @@ public class GovEngineeringController {
|
||||
public Result<IPage<Engineering>> queryPageList(@ApiIgnore @RequestBody Map<String, Object> map) {
|
||||
QueryWrapper<Engineering> wrapper = QueryGenerator.initPageQueryWrapper(Engineering.class, map);
|
||||
Page<Engineering> page = PageUtil.getPage(map);
|
||||
wrapper.lambda().ne(Engineering::getExamineState, 0);
|
||||
wrapper.orderByAsc("examine_state").orderByDesc("create_time");
|
||||
IPage<Engineering> pageList = engineeringService.getPageList(page, wrapper);
|
||||
return Result.success(pageList);
|
||||
|
||||
@ -2,12 +2,15 @@ package com.zhgd.xmgl.modules.basicdata.controller.government;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.zhgd.annotation.OperLog;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.Enterprise;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.EnterpriseMain;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.IEnterpriseService;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
|
||||
import com.zhgd.xmgl.modules.basicdata.vo.EnterpriseVo;
|
||||
import com.zhgd.xmgl.security.SecurityUser;
|
||||
import com.zhgd.xmgl.security.SecurityUtil;
|
||||
@ -43,6 +46,9 @@ public class GovEnterpriseController {
|
||||
@Autowired
|
||||
private IEnterpriseService enterpriseService;
|
||||
|
||||
@Autowired
|
||||
private ISystemUserService systemUserService;
|
||||
|
||||
/**
|
||||
* 政务分页列表查询企业
|
||||
* @return
|
||||
@ -88,7 +94,8 @@ public class GovEnterpriseController {
|
||||
@ApiOperation(value = "企业审批", notes = "企业审批", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "enterpriseId", value = "企业信息ID", paramType = "body", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "suggest", value = "审核结果(0:驳回;1:同意)", paramType = "body", required = true, dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "suggest", value = "审核结果(2:驳回;1:同意)", paramType = "body", required = true, dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "rejectReason", value = "驳回原因", paramType = "body", required = true, dataType = "Integer")
|
||||
})
|
||||
@PostMapping(value = "/examine")
|
||||
public Result<Enterprise> examine(@ApiIgnore @RequestBody Map<String, Object> map) {
|
||||
@ -99,7 +106,34 @@ public class GovEnterpriseController {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
Integer suggest = MapUtils.getInteger(map, "suggest");
|
||||
boolean ok = enterpriseService.updateInfo(enterpriseEntity, suggest);
|
||||
String rejectReason = MapUtils.getString(map, "rejectReason");
|
||||
boolean ok = enterpriseService.examine(enterpriseEntity, suggest, rejectReason);
|
||||
if (ok) {
|
||||
result.success("修改成功!");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@OperLog(operModul = "企业管理", operType = "修改", operDesc = "企业修改")
|
||||
@ApiOperation(value = "企业修改", notes = "企业修改", httpMethod = "POST")
|
||||
@PostMapping(value = "/update")
|
||||
public Result<Enterprise> update(@ApiIgnore @RequestBody EnterpriseVo enterpriseVo) {
|
||||
Result<Enterprise> result = new Result<Enterprise>();
|
||||
Enterprise enterprise = enterpriseService.getById(enterpriseVo.getEnterpriseId());
|
||||
if (enterprise == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
// 检验项目账号是否已存在
|
||||
SystemUser systemUser = systemUserService.getOne(Wrappers.<SystemUser>lambdaQuery().eq(SystemUser::getAccount, enterpriseVo.getAccount())
|
||||
.ne(SystemUser::getSn, enterprise.getEnterpriseSn()));
|
||||
if (systemUser != null) {
|
||||
result.error500("该用户账号已被使用");
|
||||
return result;
|
||||
}
|
||||
enterpriseVo.setEnterpriseSn(enterprise.getEnterpriseSn());
|
||||
boolean ok = enterpriseService.updateInfo(enterpriseVo);
|
||||
if (ok) {
|
||||
result.success("修改成功!");
|
||||
}
|
||||
@ -140,14 +174,9 @@ public class GovEnterpriseController {
|
||||
@PostMapping(value = "/getDetailById")
|
||||
public Result<EnterpriseVo> getDetailById(@ApiIgnore @RequestBody Enterprise enterpriseEntity) {
|
||||
Result<EnterpriseVo> result = new Result<EnterpriseVo>();
|
||||
Enterprise enterprise = enterpriseService.getById(enterpriseEntity.getEnterpriseId());
|
||||
if (enterprise == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
EnterpriseVo enterpriseVo = enterpriseService.getDetailById(enterpriseEntity.getEnterpriseId());
|
||||
result.setResult(enterpriseVo);
|
||||
result.setSuccess(true);
|
||||
}
|
||||
EnterpriseVo enterpriseVo = enterpriseService.getDetailById(enterpriseEntity.getEnterpriseId());
|
||||
result.setResult(enterpriseVo);
|
||||
result.setSuccess(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -1,16 +1,19 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.controller.government;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.zhgd.annotation.OperLog;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.xmgl.modules.wisdom.dto.MapEnvironAlarmDto;
|
||||
import com.zhgd.xmgl.modules.basicdata.dto.ProjectDto;
|
||||
import com.zhgd.xmgl.modules.wisdom.dto.MapAiAlarmDto;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.Enterprise;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.Project;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.IProjectService;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
|
||||
import com.zhgd.xmgl.modules.basicdata.vo.ProjectVo;
|
||||
import com.zhgd.xmgl.modules.wisdom.dto.MapAiAlarmDto;
|
||||
import com.zhgd.xmgl.modules.wisdom.dto.MapEnvironAlarmDto;
|
||||
import com.zhgd.xmgl.modules.wisdom.service.IAiMonitorAlarmService;
|
||||
import com.zhgd.xmgl.modules.wisdom.service.IEnvironmentAlarmService;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.IProjectService;
|
||||
import com.zhgd.xmgl.security.SecurityUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@ -45,6 +48,9 @@ public class GovProjectController {
|
||||
@Autowired
|
||||
private IProjectService projectService;
|
||||
|
||||
@Autowired
|
||||
private ISystemUserService systemUserService;
|
||||
|
||||
@Autowired
|
||||
private IAiMonitorAlarmService aiMonitorAlarmService;
|
||||
|
||||
@ -59,7 +65,7 @@ public class GovProjectController {
|
||||
@OperLog(operModul = "项目管理", operType = "分页查询", operDesc = "分页列表查询项目信息信息")
|
||||
@ApiOperation(value = " 分页列表查询项目信息信息", notes = "分页列表查询项目信息信息", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "state", value = "授权状态: 1(审批通过);0(待审批)", paramType = "body", dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "state", value = "授权状态: 1(审批通过);0(待审批);2(驳回)", paramType = "body", dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "projectName", value = "项目名称", paramType = "body", dataType = "String"),
|
||||
@ApiImplicitParam(name = "pageNo", value = "页数", paramType = "body", required = true, defaultValue = "1", dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "body", required = true, defaultValue = "10", dataType = "Integer")
|
||||
@ -111,18 +117,20 @@ public class GovProjectController {
|
||||
@ApiOperation(value = "项目审批", notes = "项目审批", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "projectId", value = "项目ID", paramType = "body", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "suggest", value = "审核结果(0:驳回;1:同意)", paramType = "body", required = true, dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "suggest", value = "审核结果(2:驳回;1:同意)", paramType = "body", required = true, dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "rejectReason", value = "驳回原因", paramType = "body", required = true, dataType = "Integer")
|
||||
})
|
||||
@PostMapping(value = "/examine")
|
||||
public Result<Enterprise> examine(@ApiIgnore @RequestBody Map<String, Object> map) {
|
||||
Result<Enterprise> result = new Result<Enterprise>();
|
||||
public Result<Object> examine(@ApiIgnore @RequestBody Map<String, Object> map) {
|
||||
Result<Object> result = new Result<Object>();
|
||||
String projectId = MapUtils.getString(map, "projectId");
|
||||
Project project = projectService.getById(projectId);
|
||||
if (project == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
Integer suggest = MapUtils.getInteger(map, "suggest");
|
||||
boolean ok = projectService.examine(project, suggest);
|
||||
String rejectReason = MapUtils.getString(map, "rejectReason");
|
||||
boolean ok = projectService.examine(project, suggest, rejectReason);
|
||||
if (ok) {
|
||||
result.success("修改成功!");
|
||||
}
|
||||
@ -131,6 +139,31 @@ public class GovProjectController {
|
||||
return result;
|
||||
}
|
||||
|
||||
@OperLog(operModul = "项目管理", operType = "修改", operDesc = "项目修改")
|
||||
@ApiOperation(value = "项目修改", notes = "项目修改", httpMethod = "POST")
|
||||
@PostMapping(value = "/update")
|
||||
public Result<Object> update(@ApiIgnore @RequestBody ProjectVo projectVo) {
|
||||
Result<Object> result = new Result<Object>();
|
||||
Project project = projectService.getById(projectVo.getProjectId());
|
||||
if (project == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
// 检验项目账号是否已存在
|
||||
SystemUser systemUser = systemUserService.getOne(Wrappers.<SystemUser>lambdaQuery().eq(SystemUser::getAccount, projectVo.getAccount())
|
||||
.ne(SystemUser::getSn, project.getProjectSn()));
|
||||
if (systemUser != null) {
|
||||
result.error500("该用户账号已被使用");
|
||||
return result;
|
||||
}
|
||||
projectVo.setProjectSn(project.getProjectSn());
|
||||
boolean ok = projectService.updateInfo(projectVo);
|
||||
if (ok) {
|
||||
result.success("修改成功!");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过项目SN查询项目详细信息
|
||||
*
|
||||
|
||||
@ -13,18 +13,14 @@ import com.zhgd.xmgl.modules.basicdata.entity.Engineering;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.IEngineeringService;
|
||||
import com.zhgd.xmgl.modules.basicdata.statistics.EngineeringStat;
|
||||
import com.zhgd.xmgl.modules.basicdata.vo.EngineeringVo;
|
||||
import com.zhgd.xmgl.valid.AddGroup;
|
||||
import com.zhgd.xmgl.security.SecurityUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.List;
|
||||
@ -60,6 +56,7 @@ public class EngineeringController {
|
||||
public Result<IPage<Engineering>> queryPageList(@ApiIgnore @RequestBody Map<String, Object> map) {
|
||||
LambdaQueryWrapper<Engineering> wrapper = Wrappers.<Engineering>lambdaQuery();
|
||||
Page<Engineering> page = PageUtil.getPage(map);
|
||||
wrapper.ne(Engineering::getExamineState, 0);
|
||||
wrapper.orderByDesc(Engineering::getCreateTime);
|
||||
IPage<Engineering> pageList = engineeringService.getPageList(page, wrapper);
|
||||
return Result.success(pageList);
|
||||
@ -74,12 +71,12 @@ public class EngineeringController {
|
||||
@OperLog(operModul = "工程管理", operType = "新增", operDesc = "项目报监")
|
||||
@ApiOperation(value = " 项目报监", notes = "项目报监", httpMethod = "POST")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<Engineering> add(@RequestBody @Validated(AddGroup.class) EngineeringVo engineeringVo) {
|
||||
public Result<Engineering> add(@RequestBody /*@Validated(AddGroup.class)*/ EngineeringVo engineeringVo) {
|
||||
Result<Engineering> result = new Result<Engineering>();
|
||||
Engineering engineering = engineeringService.getOne(Wrappers.<Engineering>lambdaQuery()
|
||||
.eq(Engineering::getEngineeringName, engineeringVo.getEngineeringName()));
|
||||
if (engineering != null) {
|
||||
result.error500("该工程名已被占用");
|
||||
result.error500("该工程名已存在");
|
||||
} else {
|
||||
engineeringService.saveInfo(engineeringVo);
|
||||
result.success("添加成功!");
|
||||
@ -87,6 +84,22 @@ public class EngineeringController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询是否有未提交的报监信息
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "工程管理", operType = "新增", operDesc = "查询是否有未提交的报监信息")
|
||||
@ApiOperation(value = "查询是否有未提交的报监信息", notes = "查询是否有未提交的报监信息", httpMethod = "GET")
|
||||
@GetMapping(value = "/queryUnAdd")
|
||||
public Result<Engineering> queryUnAdd() {
|
||||
Result<Engineering> result = new Result<Engineering>();
|
||||
Engineering engineering = engineeringService.getOne(Wrappers.<Engineering>lambdaQuery()
|
||||
.eq(Engineering::getExamineState, 0).eq(Engineering::getProjectSn, SecurityUtil.getUser().getSn()));
|
||||
result.data(engineering == null ? null : engineeringService.queryDetailById(engineering.getId()));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 再次申请
|
||||
*
|
||||
@ -101,7 +114,6 @@ public class EngineeringController {
|
||||
if(engineering==null) {
|
||||
result.error500("未找到对应实体");
|
||||
}else {
|
||||
engineeringVo.setExamineState(engineering.getExamineState());
|
||||
engineeringService.updateInfo(engineeringVo);
|
||||
result.success("操作成功!");
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
|
||||
import com.zhgd.xmgl.modules.basicdata.vo.ProjectVo;
|
||||
import com.zhgd.xmgl.security.SecurityUser;
|
||||
import com.zhgd.xmgl.security.SecurityUtil;
|
||||
import com.zhgd.xmgl.util.CommonUtil;
|
||||
import com.zhgd.xmgl.valid.AddGroup;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@ -60,6 +61,10 @@ public class ProjectController {
|
||||
@PostMapping(value = "/add")
|
||||
public Result<Project> add(@RequestBody @Validated(AddGroup.class) ProjectVo projectVo) {
|
||||
Result<Project> result = new Result<Project>();
|
||||
if (!CommonUtil.checkStrongPwd(projectVo.getShowPassword())) {
|
||||
result.error500("密码必须包含数字、大小写字母、特殊符号且大于8位");
|
||||
return result;
|
||||
}
|
||||
// 检验该政务项目数是否已满
|
||||
int install = projectService.count(Wrappers.<Project>lambdaQuery().eq(Project::getGovernmentSn, projectVo.getGovernmentSn()));
|
||||
int auth = governmentService.getOne(Wrappers.<Government>lambdaQuery().eq(Government::getGovernmentSn, projectVo.getGovernmentSn())).getAuthProject();
|
||||
|
||||
@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.annotation.OperLog;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.xmgl.modules.basicdata.api.arcsoft_face.FaceApi;
|
||||
import com.zhgd.xmgl.modules.wisdom.dto.WorkerInfoDto;
|
||||
import com.zhgd.xmgl.modules.wisdom.entity.WorkerInfo;
|
||||
import com.zhgd.xmgl.modules.wisdom.service.IWorkerInfoService;
|
||||
@ -44,9 +43,6 @@ public class WorkerInfoController {
|
||||
@Autowired
|
||||
private IWorkerInfoService workerInfoService;
|
||||
|
||||
@Autowired
|
||||
private FaceApi faceApi;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
@ -190,19 +186,4 @@ public class WorkerInfoController {
|
||||
public Result<Page<Map<String, Object>>> attendStat(@ApiIgnore Page page, @ApiIgnore @RequestBody Map<String, Object> map) {
|
||||
return Result.success(workerInfoService.attendanceStat(page, map));
|
||||
}
|
||||
|
||||
/**
|
||||
* 人像比对
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "人员管理", operType = "虹软", operDesc = "人像比对")
|
||||
@ApiOperation(value = "人像比对", notes = "人像比对", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "idCardFront", value = "身份证正面图片路径", paramType = "body", dataType = "String"),
|
||||
@ApiImplicitParam(name = "feature", value = "人像照片路径", paramType = "body", dataType = "String")
|
||||
})
|
||||
@PostMapping(value = "/compareFace")
|
||||
public Result<Object> compareFace(@ApiIgnore @RequestBody Map<String, Object> map) {
|
||||
return Result.success(faceApi.compareFaceFeature(MapUtils.getString(map, "idCardFront"), MapUtils.getString(map, "feature")));
|
||||
}
|
||||
}
|
||||
|
||||
@ -270,9 +270,9 @@ public class Engineering implements Serializable {
|
||||
@ApiModelProperty(value = "项目报监时间")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 工程审核状态(1:待审批;2:审批驳回;3:审批通过;)
|
||||
* 工程审核状态(0:保存不提交;1:待审批;2:审批驳回;3:审批通过;)
|
||||
*/
|
||||
@ApiModelProperty(value = "工程审核状态(1:待审批;2:审批驳回;3:审批通过;)")
|
||||
@ApiModelProperty(value = "工程审核状态(0:保存不提交;1:待审批;2:审批驳回;3:审批通过;)")
|
||||
private Integer examineState;
|
||||
/**
|
||||
* 工程状态(1:未开工;2:在建;3:在建.普通停工;4:在建.处罚停工;5:在建.完工;6:待竣工;7:竣工;8:其他)
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.zhgd.xmgl.valid.AddGroup;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@ -162,7 +159,22 @@ public class Enterprise implements Serializable {
|
||||
@Excel(name = "批准时间", width = 15)
|
||||
@ApiModelProperty(value = "批准时间")
|
||||
private Date approveTime;
|
||||
|
||||
/**
|
||||
* 逻辑删除
|
||||
*/
|
||||
@TableLogic
|
||||
@ApiModelProperty(value = "逻辑删除")
|
||||
private Integer delFlag;
|
||||
/**
|
||||
* 驳回原因
|
||||
*/
|
||||
@ApiModelProperty(value = "驳回原因")
|
||||
private String rejectReason;
|
||||
/**
|
||||
* 所属辖区
|
||||
*/
|
||||
@ApiModelProperty(value = "所属辖区")
|
||||
private String region;
|
||||
/**
|
||||
* 企业类型
|
||||
*/
|
||||
|
||||
@ -39,7 +39,7 @@ public class GovernmentConfig implements Serializable {
|
||||
*/
|
||||
@Excel(name = "配置键名", width = 15)
|
||||
@ApiModelProperty(value = "配置键名")
|
||||
private String key;
|
||||
private String configKey;
|
||||
/**
|
||||
* 配置值
|
||||
*/
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.zhgd.xmgl.valid.AddGroup;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@ -226,9 +223,9 @@ public class Project implements Serializable {
|
||||
private Date approveTime;
|
||||
|
||||
/**
|
||||
* 授权状态: 1(审批通过);0(待审批)
|
||||
* 授权状态: 1(审批通过);0(待审批);2(审批驳回)
|
||||
*/
|
||||
@ApiModelProperty(value = "授权状态: 1(审批通过);0(待审批)")
|
||||
@ApiModelProperty(value = "授权状态: 1(审批通过);0(待审批);2(审批驳回)")
|
||||
private Integer state;
|
||||
|
||||
/**
|
||||
@ -237,6 +234,19 @@ public class Project implements Serializable {
|
||||
@ApiModelProperty(value = "项目AI预警信息统计")
|
||||
private String aiAlarmStat;
|
||||
|
||||
/**
|
||||
* 逻辑删除
|
||||
*/
|
||||
@TableLogic
|
||||
@ApiModelProperty(value = "逻辑删除")
|
||||
private Integer delFlag;
|
||||
|
||||
/**
|
||||
* 驳回原因
|
||||
*/
|
||||
@ApiModelProperty(value = "驳回原因")
|
||||
private String rejectReason;
|
||||
|
||||
/**
|
||||
* AI预警状态(true预警;false正常)
|
||||
*/
|
||||
|
||||
@ -2,6 +2,7 @@ package com.zhgd.xmgl.modules.basicdata.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.zhgd.xmgl.sensitive.Sensitive;
|
||||
import com.zhgd.xmgl.sensitive.SensitiveTypeEnum;
|
||||
@ -143,4 +144,8 @@ public class SystemUser implements Serializable {
|
||||
@Excel(name = "备注", width = 15)
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
@TableLogic
|
||||
@ApiModelProperty(value = "逻辑删除")
|
||||
private Integer delFlag;
|
||||
}
|
||||
|
||||
@ -22,6 +22,6 @@
|
||||
</select>
|
||||
|
||||
<select id="getSnListFByGov" resultType="java.lang.String">
|
||||
SELECT enterprise_sn FROM enterprise where government_sn = #{governmentSn}
|
||||
SELECT enterprise_sn FROM enterprise where government_sn = #{governmentSn} AND del_flag = 0
|
||||
</select>
|
||||
</mapper>
|
||||
@ -2,7 +2,8 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhgd.xmgl.modules.basicdata.mapper.ProjectMapper">
|
||||
<sql id="detailInfo">
|
||||
p.project_sn, p.project_id, p.project_name, p.state, p.project_manage, p.project_address, p.project_tel, u.account, u.show_password, u.email, u.user_tel, g.government_name
|
||||
p.project_sn, p.project_id, p.project_name, p.state, p.project_manage, p.project_address, p.government_sn, p.project_tel, u.account, u.show_password, u.email, u.user_tel, g.government_name
|
||||
,p.reject_reason
|
||||
</sql>
|
||||
|
||||
<select id="getPageList" resultType="com.zhgd.xmgl.modules.basicdata.dto.ProjectDto">
|
||||
@ -16,12 +17,12 @@
|
||||
SELECT <include refid="detailInfo"></include> FROM project p
|
||||
INNER JOIN system_user u ON p.project_sn = u.sn AND u.is_manager = 1
|
||||
LEFT JOIN government g ON p.government_sn = g.government_sn
|
||||
WHERE p.project_sn = #{projectSn}
|
||||
WHERE p.project_sn = #{projectSn} AND p.del_flag = 0
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getSnListFByGov" resultType="java.lang.String">
|
||||
SELECT project_sn FROM project where government_sn = #{governmentSn}
|
||||
SELECT project_sn FROM project where government_sn = #{governmentSn} AND del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="pageListByGov" resultType="com.zhgd.xmgl.modules.basicdata.dto.ProjectPageDto">
|
||||
|
||||
@ -8,14 +8,14 @@
|
||||
<select id="findByUsername" resultType="com.zhgd.xmgl.modules.basicdata.entity.SystemUser" parameterType="string">
|
||||
select *
|
||||
from system_user
|
||||
where account = #{account}
|
||||
where account = #{account} AND del_flag = 0
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="getPageList" resultType="com.zhgd.xmgl.modules.basicdata.dto.SystemUserDto">
|
||||
SELECT <include refid="userInfo"></include>, d.dept_name, ur.role_id FROM system_user u
|
||||
LEFT JOIN system_dept d ON u.department = d.dept_id
|
||||
LEFT JOIN system_user_role ur ON u.user_id = ur.user_id
|
||||
LEFT JOIN system_user_role ur ON u.user_id = ur.user_id WHERE del_flag = 0
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
</mapper>
|
||||
@ -23,7 +23,9 @@ public interface IEnterpriseService extends IService<Enterprise> {
|
||||
|
||||
boolean saveInfo(EnterpriseVo enterpriseVo);
|
||||
|
||||
boolean updateInfo(Enterprise enterprise, Integer suggest);
|
||||
boolean updateInfo(EnterpriseVo enterpriseVo);
|
||||
|
||||
boolean examine(Enterprise enterprise, Integer suggest, String rejectReason);
|
||||
|
||||
EnterpriseVo getDetailById(Long enterpriseId);
|
||||
|
||||
|
||||
@ -26,7 +26,9 @@ public interface IProjectService extends IService<Project> {
|
||||
|
||||
boolean saveInfo(ProjectVo projectVo);
|
||||
|
||||
boolean examine(Project project, Integer suggest);
|
||||
boolean updateInfo(ProjectVo projectVo);
|
||||
|
||||
boolean examine(Project project, Integer suggest, String rejectReason);
|
||||
|
||||
List<String> getSnListForGov(String governmentSn);
|
||||
|
||||
|
||||
@ -10,8 +10,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.jeecg.common.util.PageUtil;
|
||||
import com.zhgd.xmgl.async.AsyncEmail;
|
||||
import com.zhgd.xmgl.modules.basicdata.dto.AppIndexTopStatDto;
|
||||
import com.zhgd.xmgl.modules.basicdata.dto.EngineeringPageDto;
|
||||
import com.zhgd.xmgl.modules.basicdata.dto.ProjectDto;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.*;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.EngineeringMapper;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.*;
|
||||
@ -65,6 +67,12 @@ public class EngineeringServiceImpl extends ServiceImpl<EngineeringMapper, Engin
|
||||
@Autowired
|
||||
private IEnvironmentAlarmService environmentAlarmService;
|
||||
|
||||
@Autowired
|
||||
private AsyncEmail asyncEmail;
|
||||
|
||||
@Autowired
|
||||
private IProjectService projectService;
|
||||
|
||||
@Override
|
||||
public Page<Engineering> getPageList(Page page, Wrapper<Engineering> wrapper) {
|
||||
Page<Engineering> pageList = this.page(page, wrapper);
|
||||
@ -91,10 +99,7 @@ public class EngineeringServiceImpl extends ServiceImpl<EngineeringMapper, Engin
|
||||
|
||||
@Override
|
||||
public boolean updateInfo(EngineeringVo engineeringVo) {
|
||||
if (engineeringVo.getExamineState() != 3) {
|
||||
engineeringVo.setExamineState(1);
|
||||
engineeringVo.setRejectReason("");
|
||||
}
|
||||
engineeringVo.setRejectReason("");
|
||||
this.updateById(engineeringVo);
|
||||
engineeringSingleService.delDetail(engineeringVo.getEngineeringSn());
|
||||
return engineeringSingleService.saveDetail(engineeringVo);
|
||||
@ -103,11 +108,9 @@ public class EngineeringServiceImpl extends ServiceImpl<EngineeringMapper, Engin
|
||||
@Override
|
||||
public boolean saveInfo(EngineeringVo engineeringVo) {
|
||||
SecurityUser user = SecurityUtil.getUser();
|
||||
engineeringVo.setState(1);
|
||||
engineeringVo.setCreateTime(new Date());
|
||||
engineeringVo.setProjectSn(user.getSn());
|
||||
engineeringVo.setEngineeringSn(CommonUtil.getUUid());
|
||||
engineeringVo.setExamineState(1);
|
||||
this.save(engineeringVo);
|
||||
return engineeringSingleService.saveDetail(engineeringVo);
|
||||
}
|
||||
@ -117,15 +120,23 @@ public class EngineeringServiceImpl extends ServiceImpl<EngineeringMapper, Engin
|
||||
String id = MapUtils.getString(map, "id");
|
||||
Integer examineState = MapUtils.getInteger(map, "suggest");
|
||||
String rejectReason = MapUtils.getString(map, "rejectReason");
|
||||
Engineering engineering = this.getById(id);
|
||||
ProjectDto projectDto = projectService.getDetailBySn(engineering.getProjectSn());
|
||||
LambdaUpdateWrapper<Engineering> wrapper = Wrappers.<Engineering>lambdaUpdate();
|
||||
wrapper.set(Engineering::getExamineState, examineState);
|
||||
wrapper.set(Engineering::getRejectReason, rejectReason);
|
||||
String content = "工程报监审批已驳回; 工程名称:"+ engineering.getEngineeringName() + "; 驳回原因:" + rejectReason;
|
||||
// 项目报监审核通过
|
||||
if (examineState == 3) {
|
||||
wrapper.set(Engineering::getState, 2);
|
||||
content = "工程报监审批已通过; 工程名称:"+ engineering.getEngineeringName();
|
||||
}
|
||||
wrapper.eq(Engineering::getId, id);
|
||||
return this.update(wrapper);
|
||||
boolean flag = this.update(wrapper);
|
||||
if (flag) {
|
||||
asyncEmail.sendEmail(projectDto.getGovernmentSn(), projectDto.getEmail(), "工程报监审批结果通知", content);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,22 +1,20 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.*;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.AnnexFile;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.EngineeringMain;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.EngineeringMainPerson;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.EngineeringSingle;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.EngineeringSingleMapper;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.*;
|
||||
import com.zhgd.xmgl.modules.basicdata.vo.EngineeringVo;
|
||||
import com.zhgd.xmgl.modules.safety.entity.EnterpriseScore;
|
||||
import com.zhgd.xmgl.modules.safety.service.IEnterpriseScoreService;
|
||||
import com.zhgd.xmgl.security.SecurityUtil;
|
||||
import com.zhgd.xmgl.util.ParamEnum;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -51,29 +49,26 @@ public class EngineeringSingleServiceImpl extends ServiceImpl<EngineeringSingleM
|
||||
engineeringSingle.setEngineeringSn(engineeringVo.getEngineeringSn());
|
||||
}
|
||||
this.saveBatch(engineeringVo.getEngineeringSingles());
|
||||
for (AnnexFile annexFile : engineeringVo.getAnnexFiles()) {
|
||||
annexFile.setRelevanceId(engineeringVo.getEngineeringSn());
|
||||
annexFile.setFileType(ParamEnum.AnnexFileType.ENGINEERING.getValue());
|
||||
}
|
||||
annexFileService.saveBatch(engineeringVo.getAnnexFiles());
|
||||
List<EnterpriseScore> scoreList = new ArrayList<>();
|
||||
for (EngineeringMain engineeringMain : engineeringVo.getEngineeringMains()) {
|
||||
engineeringMain.setEngineeringSn(engineeringVo.getEngineeringSn());
|
||||
engineeringMainService.save(engineeringMain);
|
||||
for (EngineeringMainPerson engineeringMainPerson : engineeringMain.getEngineeringMainPersonList()) {
|
||||
engineeringMainPerson.setMainId(engineeringMain.getId());
|
||||
engineeringMainPerson.setEngineeringSn(engineeringVo.getEngineeringSn());
|
||||
if (engineeringVo.getAnnexFiles() != null) {
|
||||
for (AnnexFile annexFile : engineeringVo.getAnnexFiles()) {
|
||||
annexFile.setRelevanceId(engineeringVo.getEngineeringSn());
|
||||
annexFile.setFileType(ParamEnum.AnnexFileType.ENGINEERING.getValue());
|
||||
}
|
||||
annexFileService.saveBatch(engineeringVo.getAnnexFiles());
|
||||
}
|
||||
if (engineeringVo.getEngineeringMains() != null) {
|
||||
for (EngineeringMain engineeringMain : engineeringVo.getEngineeringMains()) {
|
||||
engineeringMain.setEngineeringSn(engineeringVo.getEngineeringSn());
|
||||
engineeringMainService.save(engineeringMain);
|
||||
if(engineeringMain.getEngineeringMainPersonList() != null) {
|
||||
for (EngineeringMainPerson engineeringMainPerson : engineeringMain.getEngineeringMainPersonList()) {
|
||||
engineeringMainPerson.setMainId(engineeringMain.getId());
|
||||
engineeringMainPerson.setEngineeringSn(engineeringVo.getEngineeringSn());
|
||||
}
|
||||
engineeringMainPersonService.saveBatch(engineeringMain.getEngineeringMainPersonList());
|
||||
}
|
||||
}
|
||||
engineeringMainPersonService.saveBatch(engineeringMain.getEngineeringMainPersonList());
|
||||
EnterpriseScore enterpriseScore = new EnterpriseScore();
|
||||
enterpriseScore.setEnterpriseSn(engineeringMain.getEnterpriseSn());
|
||||
enterpriseScore.setEngineeringSn(engineeringVo.getEngineeringSn());
|
||||
enterpriseScore.setEnterpriseType(engineeringMain.getType());
|
||||
enterpriseScore.setCreateBy(projectService.getOne(Wrappers.<Project>lambdaQuery().eq(Project::getProjectSn, SecurityUtil.getUser().getSn())).getGovernmentSn());
|
||||
enterpriseScore.setCreateTime(new Date());
|
||||
scoreList.add(enterpriseScore);
|
||||
}
|
||||
enterpriseScoreService.saveBatch(scoreList);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -86,9 +81,11 @@ public class EngineeringSingleServiceImpl extends ServiceImpl<EngineeringSingleM
|
||||
List<EngineeringMain> engineeringMains = engineeringMainService.list(Wrappers.<EngineeringMain>lambdaQuery()
|
||||
.eq(EngineeringMain::getEngineeringSn, engineeringSn));
|
||||
List<Long> mainIds = engineeringMains.stream().map(m -> m.getId()).collect(Collectors.toList());
|
||||
engineeringMainPersonService.remove(Wrappers.<EngineeringMainPerson>lambdaQuery()
|
||||
.in(EngineeringMainPerson::getMainId, mainIds));
|
||||
engineeringMainService.removeByIds(mainIds);
|
||||
if (mainIds.size() > 0) {
|
||||
engineeringMainPersonService.remove(Wrappers.<EngineeringMainPerson>lambdaQuery()
|
||||
.in(EngineeringMainPerson::getMainId, mainIds));
|
||||
engineeringMainService.removeByIds(mainIds);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.jeecg.common.util.PageUtil;
|
||||
import com.zhgd.mybatis.Aes;
|
||||
import com.zhgd.xmgl.async.AsyncEmail;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.*;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.EnterpriseMapper;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.ProjectMapper;
|
||||
@ -51,6 +52,9 @@ public class EnterpriseServiceImpl extends ServiceImpl<EnterpriseMapper, Enterpr
|
||||
@Autowired
|
||||
private IEnterpriseMainLicenseService enterpriseMainLicenseService;
|
||||
|
||||
@Autowired
|
||||
private AsyncEmail asyncEmail;
|
||||
|
||||
@Override
|
||||
public Page<Enterprise> pageList(Map<String, Object> map) {
|
||||
Integer mainType = MapUtils.getInteger(map, "mainType");
|
||||
@ -72,7 +76,7 @@ public class EnterpriseServiceImpl extends ServiceImpl<EnterpriseMapper, Enterpr
|
||||
wrapper.eq("a.state", state);
|
||||
}
|
||||
wrapper.eq("a.government_sn", SecurityUtil.getUser().getSn());
|
||||
wrapper.orderByAsc("a.state").orderByDesc("a.create_time");
|
||||
wrapper.orderByDesc("a.create_time");
|
||||
return baseMapper.pageList(page, wrapper);
|
||||
}
|
||||
|
||||
@ -121,13 +125,45 @@ public class EnterpriseServiceImpl extends ServiceImpl<EnterpriseMapper, Enterpr
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateInfo(Enterprise enterprise, Integer suggest) {
|
||||
public boolean updateInfo(EnterpriseVo enterpriseVo) {
|
||||
List<EnterpriseMain> enterpriseMainList = enterpriseMainService.list(Wrappers.<EnterpriseMain>lambdaQuery().eq(EnterpriseMain::getEnterpriseSn, enterpriseVo.getEnterpriseSn()));
|
||||
List<Long> ids = enterpriseMainList.stream().map(l -> l.getId()).collect(Collectors.toList());
|
||||
enterpriseMainLicenseService.remove(Wrappers.<EnterpriseMainLicense>lambdaQuery().in(EnterpriseMainLicense::getMainId, ids));
|
||||
enterpriseMainService.removeByIds(ids);
|
||||
this.updateById(enterpriseVo);
|
||||
SystemUser systemUser = systemUserService.getOne(Wrappers.<SystemUser>lambdaQuery().eq(SystemUser::getSn, enterpriseVo.getEnterpriseSn()).eq(SystemUser::getIsManager, 1));
|
||||
systemUser.setAccount(enterpriseVo.getAccount());
|
||||
systemUser.setPassword(Aes.encrypt(enterpriseVo.getPassword()));
|
||||
systemUser.setShowPassword(enterpriseVo.getPassword());
|
||||
systemUser.setRealName(enterpriseVo.getRealName());
|
||||
systemUser.setState(enterpriseVo.getState());
|
||||
systemUser.setUserTel(enterpriseVo.getPhone());
|
||||
systemUser.setSn(enterpriseVo.getEnterpriseSn());
|
||||
systemUser.setEmail(enterpriseVo.getEmail());
|
||||
systemUserService.updateById(systemUser);
|
||||
for (EnterpriseMain enterpriseMain : enterpriseVo.getEnterpriseMains()) {
|
||||
enterpriseMain.setEnterpriseSn(enterpriseVo.getEnterpriseSn());
|
||||
enterpriseMainService.save(enterpriseMain);
|
||||
for (EnterpriseMainLicense licenses : enterpriseMain.getLicenses()) {
|
||||
licenses.setEnterpriseSn(enterpriseVo.getEnterpriseSn());
|
||||
licenses.setMainId(enterpriseMain.getId());
|
||||
}
|
||||
enterpriseMainLicenseService.saveBatch(enterpriseMain.getLicenses());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean examine(Enterprise enterprise, Integer suggest, String rejectReason) {
|
||||
SystemUser systemUser = systemUserService.getOne(Wrappers.<SystemUser>lambdaQuery()
|
||||
.eq(SystemUser::getSn, enterprise.getEnterpriseSn()).eq(SystemUser::getIsManager, true));
|
||||
LambdaUpdateWrapper<Enterprise> enterpriseWrapper = Wrappers.<Enterprise>lambdaUpdate();
|
||||
enterpriseWrapper.eq(Enterprise::getEnterpriseId, enterprise.getEnterpriseId());
|
||||
enterpriseWrapper.set(Enterprise::getState, suggest);
|
||||
String content = "";
|
||||
if (suggest == 1) {
|
||||
// 修改企业状态为可用
|
||||
LambdaUpdateWrapper<Enterprise> enterpriseWrapper = Wrappers.<Enterprise>lambdaUpdate();
|
||||
enterpriseWrapper.set(Enterprise::getApproveTime, new Date());
|
||||
enterpriseWrapper.set(Enterprise::getState, 1);
|
||||
enterpriseWrapper.eq(Enterprise::getEnterpriseId, enterprise.getEnterpriseId());
|
||||
this.update(enterpriseWrapper);
|
||||
// 启用企业账号
|
||||
LambdaUpdateWrapper<SystemUser> userWrapper = Wrappers.<SystemUser>lambdaUpdate();
|
||||
@ -135,15 +171,20 @@ public class EnterpriseServiceImpl extends ServiceImpl<EnterpriseMapper, Enterpr
|
||||
userWrapper.eq(SystemUser::getSn, enterprise.getEnterpriseSn());
|
||||
userWrapper.eq(SystemUser::getIsManager, true);
|
||||
systemUserService.update(userWrapper);
|
||||
content = "企业审批已通过; 企业名称:"+ enterprise.getEnterpriseName() + "; 企业账号:" + systemUser.getAccount() + ",密码:" + systemUser.getShowPassword();
|
||||
} else {
|
||||
// 审批不通过,删除企业以及企业账号信息
|
||||
systemUserService.remove(Wrappers.<SystemUser>lambdaQuery()
|
||||
.eq(SystemUser::getSn, enterprise.getEnterpriseSn()).eq(SystemUser::getIsManager, true));
|
||||
enterpriseMainLicenseService.remove(Wrappers.<EnterpriseMainLicense>lambdaQuery()
|
||||
.eq(EnterpriseMainLicense::getEnterpriseSn, enterprise.getEnterpriseSn()));
|
||||
enterpriseMainService.remove(Wrappers.<EnterpriseMain>lambdaQuery().eq(EnterpriseMain::getEnterpriseSn, enterprise.getEnterpriseSn()));
|
||||
// enterpriseMainLicenseService.remove(Wrappers.<EnterpriseMainLicense>lambdaQuery()
|
||||
// .eq(EnterpriseMainLicense::getEnterpriseSn, enterprise.getEnterpriseSn()));
|
||||
// enterpriseMainService.remove(Wrappers.<EnterpriseMain>lambdaQuery().eq(EnterpriseMain::getEnterpriseSn, enterprise.getEnterpriseSn()));
|
||||
enterpriseWrapper.set(Enterprise::getRejectReason, rejectReason);
|
||||
this.update(enterpriseWrapper);
|
||||
this.removeById(enterprise.getEnterpriseId());
|
||||
content = "企业审批已驳回; 企业名称:"+ enterprise.getEnterpriseName() + "; 驳回原因:" + rejectReason;
|
||||
}
|
||||
asyncEmail.sendEmail(enterprise.getGovernmentSn(), systemUser.getEmail(), "企业审批结果通知", content);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -173,6 +214,7 @@ public class EnterpriseServiceImpl extends ServiceImpl<EnterpriseMapper, Enterpr
|
||||
if(StringUtils.isNotBlank(enterpriseName)) {
|
||||
query.like("c.enterprise_name", enterpriseName);
|
||||
}
|
||||
query.eq("c.del_flag", 0);
|
||||
return baseMapper.listByMainType(query);
|
||||
}
|
||||
|
||||
|
||||
@ -110,6 +110,9 @@ public class FileDetailServiceImpl extends ServiceImpl<FileDetailMapper, FileDet
|
||||
result.put("url", imagePath + rName);
|
||||
result.put("originalFilename", orgName);
|
||||
result.put("filename", rName);
|
||||
result.put("size", file.getSize());
|
||||
result.put("contentType", file.getContentType());
|
||||
result.put("ext", fileExtension);
|
||||
} catch (Exception ex) {
|
||||
log.error(ex.getMessage());
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.jeecg.common.util.PageUtil;
|
||||
import com.zhgd.mybatis.Aes;
|
||||
import com.zhgd.xmgl.async.AsyncEmail;
|
||||
import com.zhgd.xmgl.modules.basicdata.dto.ProjectDto;
|
||||
import com.zhgd.xmgl.modules.basicdata.dto.ProjectPageDto;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.Project;
|
||||
@ -51,6 +52,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
||||
@Autowired
|
||||
private IEnvironmentAlarmService environmentAlarmService;
|
||||
|
||||
@Autowired
|
||||
private AsyncEmail asyncEmail;
|
||||
|
||||
@Override
|
||||
public Page<ProjectDto> getPageList(Map<String, Object> map) {
|
||||
SecurityUser user = SecurityUtil.getUser();
|
||||
@ -65,7 +69,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
||||
if (StringUtils.isNotBlank(projectName)) {
|
||||
wrapper.like("p.project_name", projectName);
|
||||
}
|
||||
wrapper.orderByAsc("p.state").orderByDesc("p.create_time");
|
||||
wrapper.orderByDesc("p.create_time");
|
||||
return baseMapper.getPageList(page, wrapper);
|
||||
}
|
||||
|
||||
@ -91,16 +95,16 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
||||
public boolean saveInfo(ProjectVo projectVo) {
|
||||
projectVo.setProjectSn(CommonUtil.getUUid());
|
||||
projectVo.setCreateTime(new Date());
|
||||
projectVo.setProjectTel(projectVo.getPhone());
|
||||
projectVo.setProjectTel(projectVo.getUserTel());
|
||||
boolean flag = this.save(projectVo);
|
||||
if (flag) {
|
||||
SystemUser systemUser = new SystemUser();
|
||||
systemUser.setAccount(projectVo.getAccount());
|
||||
systemUser.setPassword(Aes.encrypt(projectVo.getPassword()));
|
||||
systemUser.setShowPassword(projectVo.getPassword());
|
||||
systemUser.setPassword(Aes.encrypt(projectVo.getShowPassword()));
|
||||
systemUser.setShowPassword(projectVo.getShowPassword());
|
||||
systemUser.setIsManager(true);
|
||||
systemUser.setState(projectVo.getState());
|
||||
systemUser.setUserTel(projectVo.getPhone());
|
||||
systemUser.setUserTel(projectVo.getUserTel());
|
||||
systemUser.setSn(projectVo.getProjectSn());
|
||||
systemUser.setAccountType(4);
|
||||
systemUser.setEmail(projectVo.getEmail());
|
||||
@ -112,23 +116,44 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean examine(Project project, Integer suggest) {
|
||||
public boolean updateInfo(ProjectVo projectVo) {
|
||||
this.updateById(projectVo);
|
||||
SystemUser systemUser = systemUserMapper.selectOne(Wrappers.<SystemUser>lambdaQuery().eq(SystemUser::getSn, projectVo.getProjectSn()).eq(SystemUser::getIsManager, 1));
|
||||
systemUser.setAccount(projectVo.getAccount());
|
||||
systemUser.setPassword(Aes.encrypt(projectVo.getShowPassword()));
|
||||
systemUser.setShowPassword(projectVo.getShowPassword());
|
||||
systemUser.setUserTel(projectVo.getUserTel());
|
||||
systemUser.setSn(projectVo.getProjectSn());
|
||||
systemUser.setEmail(projectVo.getEmail());
|
||||
systemUser.setRealName(projectVo.getProjectName());
|
||||
systemUserMapper.updateById(systemUser);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean examine(Project project, Integer suggest, String rejectReason) {
|
||||
SystemUser systemUser = systemUserMapper.selectOne(Wrappers.<SystemUser>lambdaQuery()
|
||||
.eq(SystemUser::getSn, project.getProjectSn()).eq(SystemUser::getIsManager, true));
|
||||
LambdaUpdateWrapper<Project> projectWrapper = Wrappers.<Project>lambdaUpdate();
|
||||
projectWrapper.set(Project::getState, suggest);
|
||||
projectWrapper.eq(Project::getProjectId, project.getProjectId());
|
||||
String content = "";
|
||||
if (suggest == 1) {
|
||||
LambdaUpdateWrapper<Project> projectWrapper = Wrappers.<Project>lambdaUpdate();
|
||||
projectWrapper.set(Project::getState, 1);
|
||||
projectWrapper.set(Project::getApproveTime, new Date());
|
||||
projectWrapper.eq(Project::getProjectId, project.getProjectId());
|
||||
this.update(projectWrapper);
|
||||
LambdaUpdateWrapper<SystemUser> userWrapper = Wrappers.<SystemUser>lambdaUpdate();
|
||||
userWrapper.set(SystemUser::getState, 1);
|
||||
userWrapper.eq(SystemUser::getUserId, systemUser.getUserId());
|
||||
this.update(projectWrapper);
|
||||
systemUserMapper.update(systemUser, userWrapper);
|
||||
content = "项目审批已通过; 项目名称:"+ project.getProjectName() + ", 项目账号:" + systemUser.getAccount() + ", 密码:" + systemUser.getShowPassword();
|
||||
} else {
|
||||
projectWrapper.set(Project::getRejectReason, rejectReason);
|
||||
systemUserMapper.deleteById(systemUser.getUserId());
|
||||
this.update(projectWrapper);
|
||||
this.removeById(project.getProjectId());
|
||||
content = "项目审批已驳回; 项目名称:"+ project.getProjectName() + ", 驳回原因:" + rejectReason;
|
||||
}
|
||||
asyncEmail.sendEmail(project.getGovernmentSn(), systemUser.getEmail(), "项目审批结果通知", content);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -147,6 +172,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
||||
}
|
||||
wrapper.eq(Project::getGovernmentSn, user.getSn());
|
||||
wrapper.eq(Project::getState, 1);
|
||||
wrapper.eq(Project::getDelFlag, 0);
|
||||
Page<Project> page = PageUtil.getPage(map);
|
||||
return baseMapper.pageListByGov(page, wrapper);
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ public class ProjectVo extends Project {
|
||||
|
||||
@NotBlank(message = "手机号码不能为空", groups = {AddGroup.class})
|
||||
@ApiModelProperty(value="手机号")
|
||||
private String phone;
|
||||
private String userTel;
|
||||
|
||||
@NotBlank(message = "登录账号不能为空", groups = {AddGroup.class})
|
||||
@ApiModelProperty(value="账号")
|
||||
@ -22,7 +22,7 @@ public class ProjectVo extends Project {
|
||||
|
||||
@NotBlank(message = "密码不能为空", groups = {AddGroup.class})
|
||||
@ApiModelProperty(value="密码")
|
||||
private String password;
|
||||
private String showPassword;
|
||||
|
||||
@NotBlank(message = "邮箱不能为空", groups = {AddGroup.class})
|
||||
@ApiModelProperty(value="邮箱")
|
||||
|
||||
@ -1,36 +0,0 @@
|
||||
package com.zhgd.xmgl.task;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.zhgd.xmgl.modules.basicdata.api.image_ai.ImageApi;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @description: AI监控预警定时任务
|
||||
**/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ImageAiTask {
|
||||
|
||||
|
||||
/**
|
||||
* ,每一个小时检查预警异常信息
|
||||
*/
|
||||
// @Scheduled(cron = "0 0 * * * ?")
|
||||
private void safetyHelmet() {
|
||||
log.info("=========AI识别预警任务执行开始========");
|
||||
JSONArray jsonArray = ImageApi.safetyHelmet("rtsp://admin:jxj12345@10.0.77.104:554/Streaming/Channels/101");
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
String className = jsonArray.getJSONObject(i).getString("className");
|
||||
// TODO 出现问题进行AI报警数据上报
|
||||
if (className.contains("unsafe")) {
|
||||
|
||||
}
|
||||
}
|
||||
log.info("=========AI识别预警任务执行结束========");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(ImageApi.safetyHelmet("rtsp://admin:jxj12345@10.0.77.104:554/Streaming/Channels/101"));
|
||||
}
|
||||
}
|
||||
@ -26,6 +26,7 @@ public class EmailsUtil {
|
||||
|
||||
public boolean SendEmails(EmailParaForm emailParaForm) {
|
||||
boolean isSucc = false;
|
||||
mp = new MimeMultipart();
|
||||
if (emailParaForm == null) {
|
||||
return isSucc;
|
||||
}
|
||||
@ -156,7 +157,7 @@ public class EmailsUtil {
|
||||
}
|
||||
|
||||
public boolean send(String fromUser, String receiveUser, String title, String content) {
|
||||
return send(fromUser, receiveUser, title, content, "");
|
||||
return send(fromUser, receiveUser, title, content, null);
|
||||
}
|
||||
|
||||
public boolean send(String fromUser, String receiveUser, String title, String content, String fileAttachments) {
|
||||
@ -178,8 +179,7 @@ public class EmailsUtil {
|
||||
return isSucc;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// EmailsUtil.send("1547224827@qq.com", "维基百科", "自由的百科全书:维基百科是一个内容自由、任何人都能参与、并有多种语言的百科全书协作计划...");
|
||||
// EmailsUtil.send("1547224827@qq.com", "测试邮件", "自由的百科全书:维基百科是一个内容自由、任何人都能参与、并有多种语言的百科全书协作计划...");
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,7 @@ http.port=6023
|
||||
server.port=6688
|
||||
# 数据库配置
|
||||
#182.90.224.147
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/wisdomsitezw?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&useSSL=false
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/wisdomsitezw_whlt?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&useSSL=false
|
||||
# 数据库加密配置
|
||||
#spring.datasource.username=ENC(XR4C/hvTYCUqudS49Wh/jA==)
|
||||
#spring.datasource.password=ENC(hHkiHEc6vSWjqfOtg2/2Uiihs0vX3l7V)
|
||||
@ -22,51 +22,14 @@ mqtt-scope=devTopic
|
||||
spring.redis.database=1
|
||||
spring.redis.host=localhost
|
||||
spring.redis.port=6379
|
||||
#文件存储配置
|
||||
spring.file-storage.default-platform=local
|
||||
spring.file-storage.thumbnail-suffix=.jpg
|
||||
spring.file-storage.minio[0].platform=minio-1
|
||||
spring.file-storage.minio[0].enable-storage=true
|
||||
spring.file-storage.minio[0].access-key=minioadmin
|
||||
spring.file-storage.minio[0].secret-key=minioadmin
|
||||
spring.file-storage.minio[0].end-point=http://182.90.224.147:9000
|
||||
spring.file-storage.minio[0].bucket-name=wisdomisitezw
|
||||
spring.file-storage.minio[0].domain=http://182.90.224.147:9000/wisdomisitezw/
|
||||
spring.file-storage.minio[0].base-path=
|
||||
#spring.file-storage.default-platform=local
|
||||
#spring.file-storage.thumbnail-suffix=.jpg
|
||||
#spring.file-storage.minio[0].platform=minio-1
|
||||
#spring.file-storage.minio[0].enable-storage=true
|
||||
#spring.file-storage.minio[0].access-key=minioadmin
|
||||
#spring.file-storage.minio[0].secret-key=minioadmin
|
||||
#spring.file-storage.minio[0].end-point=http://127.0.0.1:9000
|
||||
#spring.file-storage.minio[0].bucket-name=wisdomisitezw
|
||||
#spring.file-storage.minio[0].domain=http://127.0.0.1:9000/wisdomisitezw/
|
||||
#spring.file-storage.minio[0].base-path=
|
||||
#客户端 License相关配置
|
||||
|
||||
|
||||
license.licensePath=D:/license_demo/client/license.lic
|
||||
license.publicKeysStorePath=D:/license_demo/client/publicCerts.keystore
|
||||
# admin中对应的地址及实例名
|
||||
spring.boot.admin.client.instance.service-url=http://localhost:6023
|
||||
spring.boot.admin.client.instance.name=dev
|
||||
|
||||
#视频监控API
|
||||
#artemisConfig.host=182.101.141.23:18443
|
||||
#artemisConfig.appKey=24017757
|
||||
#artemisConfig.appSecret=VJz0FbzmE6drPQ7egsBi
|
||||
artemisConfig.host=120.236.122.37:81
|
||||
artemisConfig.appKey=27543152
|
||||
artemisConfig.appSecret=Xyi1y9udD7dGFGsS9d9w
|
||||
|
||||
#opencv截取视频画面文件地址
|
||||
opencv.filePath=D://opencv//
|
||||
|
||||
#虹软人脸识别
|
||||
arcsoft.appId=13eRvuSeQYts8Tqcrqy4yFyg7h6XQqdUGkjJuh9ct2E2
|
||||
arcsoft.sdkKey=GLc2xHQ7yAwNxrWctSgNgVqwYqMTbz9RKTWWHQNMdJPU
|
||||
arcsoft.linux.sdkKey=
|
||||
arcsoft.dllPath=D:/dll
|
||||
|
||||
#配置web页面入口
|
||||
magic-api.resource.location=D://data//magic-api
|
||||
magic-api.security.username=admin
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
"groupId" : "1f3d3e5b9fe340bab84de67b0de08f44",
|
||||
"name" : "在建项目指标",
|
||||
"createTime" : null,
|
||||
"updateTime" : 1688352901714,
|
||||
"updateTime" : 1689678565388,
|
||||
"lock" : null,
|
||||
"createBy" : null,
|
||||
"updateBy" : "admin",
|
||||
@ -34,4 +34,4 @@
|
||||
"responseBodyDefinition" : null
|
||||
}
|
||||
================================
|
||||
return db.selectOne("SELECT IFNULL(SUM(IF(major_project_type = 1, 1, 0)), 0) importance, IFNULL(SUM(IF(project_type = 1 AND state = 1, 1, 0)), 0) bridge, IFNULL(SUM(IF(project_type = 2 AND state = 1, 1, 0)), 0) tunnel, IFNULL(SUM(IF(project_type = 3 AND state = 1, 1, 0)), 0) station, IFNULL(SUM(IF(build_status in (0,1), 1, 0)), 0) newBuild, IFNULL(SUM(IF(build_status = 5, 1, 0)), 0) reBuild, IFNULL(SUM(IF(build_status = 6, 1, 0)), 0) extension, IFNULL(SUM(IF(build_status in (1, 5, 6), 1, 0)), 0) total, IFNULL(SUM(IF(build_status = 4, 1, 0)), 0) finished, IFNULL(SUM(IF(build_status = 2, 1, 0)), 0) shutdown, IFNULL(SUM(IF(build_status in (1, 2, 4), 1, 0)), 0) total1 FROM project WHERE #project ")
|
||||
return db.selectOne("SELECT IFNULL(SUM(IF(major_project_type = 1 AND state = 1, 1, 0)), 0) importance, IFNULL(SUM(IF(project_type = 1 AND state = 1, 1, 0)), 0) bridge, IFNULL(SUM(IF(project_type = 2 AND state = 1, 1, 0)), 0) tunnel, IFNULL(SUM(IF(project_type = 3 AND state = 1, 1, 0)), 0) station, IFNULL(SUM(IF(build_status in (0,1) AND state = 1, 1, 0)), 0) newBuild, IFNULL(SUM(IF(build_status = 5, 1, 0)), 0) reBuild, IFNULL(SUM(IF(build_status = 6, 1, 0)), 0) extension, IFNULL(SUM(IF(build_status in (0, 1, 5, 6) AND state = 1, 1, 0)), 0) total, IFNULL(SUM(IF(build_status = 4, 1, 0)), 0) finished, IFNULL(SUM(IF(build_status = 2, 1, 0)), 0) shutdown, IFNULL(SUM(IF(build_status in (1, 2, 4), 1, 0)), 0) total1 FROM project WHERE #project ")
|
||||
@ -5,7 +5,7 @@
|
||||
"groupId" : "1f3d3e5b9fe340bab84de67b0de08f44",
|
||||
"name" : "投资管理",
|
||||
"createTime" : null,
|
||||
"updateTime" : 1688970096225,
|
||||
"updateTime" : 1689561440845,
|
||||
"lock" : null,
|
||||
"createBy" : "admin",
|
||||
"updateBy" : "admin",
|
||||
@ -39,7 +39,8 @@ BigDecimal big = new BigDecimal(10000);
|
||||
result.put("paymentByMonth", paymentByMonth.divide(big))
|
||||
result.put("applyAmountByMonth", applyAmountByMonth.divide(big))
|
||||
result.put("realPayAmountByMonth", realPayAmountByMonth.divide(big))
|
||||
result.put("unPayAmountByMonth", applyAmountByMonth.subtract(realPayAmountByMonth).divide(big))
|
||||
var unPayAmountByMonth = applyAmountByMonth.subtract(realPayAmountByMonth);
|
||||
result.put("unPayAmountByMonth", unPayAmountByMonth > 0 ? unPayAmountByMonth.divide(big) : 0)
|
||||
|
||||
result.put("totalAmount", totalAmount.divide(big))
|
||||
result.put("payRatio", realPayAmountTotal == 0 ? 0 : realPayAmountTotal.divide(totalAmount, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).doubleValue())
|
||||
|
||||
25
src/main/resources/magic/api/监管决策BI/查询项目详细信息.ms
Normal file
25
src/main/resources/magic/api/监管决策BI/查询项目详细信息.ms
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"properties" : { },
|
||||
"id" : "3f938e315b6a4570aa511131dec63fbd",
|
||||
"script" : null,
|
||||
"groupId" : "485e36d471af4f809398babc4abadafe",
|
||||
"name" : "查询项目详细信息",
|
||||
"createTime" : null,
|
||||
"updateTime" : 1689755920273,
|
||||
"lock" : null,
|
||||
"createBy" : null,
|
||||
"updateBy" : "admin",
|
||||
"path" : "/api/index/projectList",
|
||||
"method" : "GET",
|
||||
"parameters" : [ ],
|
||||
"options" : [ ],
|
||||
"requestBody" : "",
|
||||
"headers" : [ ],
|
||||
"paths" : [ ],
|
||||
"responseBody" : null,
|
||||
"description" : null,
|
||||
"requestBodyDefinition" : null,
|
||||
"responseBodyDefinition" : null
|
||||
}
|
||||
================================
|
||||
return db.select("SELECT * FROM project WHERE state = 1 AND #gov")
|
||||
Loading…
x
Reference in New Issue
Block a user