综合查询接口

This commit is contained in:
cwchen 2025-04-02 16:41:15 +08:00
parent e5c7830410
commit 2adb518fbc
16 changed files with 224 additions and 44 deletions

View File

@ -27,5 +27,17 @@
</jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
<data-source source="LOCAL" name="yn_img_tool@127.0.0.1" uuid="826f3ee5-e63f-4742-9b4f-b71894453330">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://127.0.0.1:3306/yn_img_tool?useUnicode=true&amp;characterEncoding=utf-8&amp;allowMultiQueries=true&amp;useSSL=false</jdbc-url>
<jdbc-additional-properties>
<property name="com.intellij.clouds.kubernetes.db.host.port" />
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
<property name="com.intellij.clouds.kubernetes.db.container.port" />
</jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

View File

@ -9,6 +9,7 @@ import com.bonus.imgTool.system.vo.EncryptedReq;
import com.bonus.imgTool.utils.ServerResponse;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -31,6 +32,13 @@ public class SynthesisQueryController {
@Resource(name = "SynthesisQueryService")
private SynthesisQueryService synthesisQueryService;
@ApiOperation("综合查询-照片综合查询-照片数量")
@PostMapping(value = "getImgNum")
@DecryptAndVerify(decryptedClass = QueryParamDto.class)
public ServerResponse getImgNum(EncryptedReq<QueryParamDto> data) {
return synthesisQueryService.getImgNum(data.getData());
}
@PostMapping(value = "getImgList")
@DecryptAndVerify(decryptedClass = QueryParamDto.class)
@LogAnnotation(operModul = "综合查询-照片综合查询", operation = "查询照片", operDesc = "系统级事件",operType="查询")

View File

@ -1,6 +1,7 @@
package com.bonus.imgTool.backstage.dao;
import com.bonus.imgTool.backstage.entity.QueryParamDto;
import com.bonus.imgTool.backstage.entity.SynthesisNumVo;
import com.bonus.imgTool.backstage.entity.SynthesisQueryVo;
import org.springframework.stereotype.Repository;
@ -15,6 +16,16 @@ import java.util.List;
*/
@Repository(value = "SynthesisQueryDao")
public interface SynthesisQueryDao {
/**
* 综合查询-照片综合查询-照片数量
* @param dto
* @return SynthesisNumVo
* @author cwchen
* @date 2025/4/2 15:40
*/
SynthesisNumVo getImgNum(QueryParamDto dto);
/**
* 照片综合查询
* @param dto

View File

@ -2,6 +2,8 @@ package com.bonus.imgTool.backstage.entity;
import lombok.Data;
import java.util.List;
/**
* @className:QueryParamDto
* @author:cwchen
@ -16,8 +18,20 @@ public class QueryParamDto {
* 1.我的收藏 2.最近上传
*/
private int queryType;
/**用户id*/
/**
* 用户id
*/
private long userId;
/**
* 用户管理的工程
*/
private List<Long> proIds;
/**
* 角色级别 0.项目部 1.分公司
*/
private String roleLevel;
private int pageNum = 1;
private int pageSize = 15;
}

View File

@ -0,0 +1,27 @@
package com.bonus.imgTool.backstage.entity;
import lombok.Data;
/**
* @className:SynthesisNumVo
* @author:cwchen
* @date:2025-04-02-14:22
* @version:1.0
* @description:综合查询各类型图片数量
*/
@Data
public class SynthesisNumVo {
/**总照片数量*/
private int totalNum;
/**安全违章*/
private int safetyVioNum;
/**质量检查*/
private int qualityInsNum;
/**安全措施落实*/
private int safetyMeasNum;
/**协调照片*/
private int coordinatedPhotoNum;
/**重要事项及宣传类*/
private int importIssuesAndPublicityNum;
}

View File

@ -15,7 +15,7 @@ import java.util.Date;
@Data
public class SynthesisQueryVo {
private String id;
private Long id;
/**
* 原图图片路径
*/

View File

@ -11,6 +11,16 @@ import com.bonus.imgTool.utils.ServerResponse;
* @description:综合查询
*/
public interface SynthesisQueryService {
/**
* 综合查询-照片综合查询-照片数量
* @param data
* @return ServerResponse
* @author cwchen
* @date 2025/4/2 14:59
*/
ServerResponse getImgNum(QueryParamDto data);
/**
* 照片综合查询
* @param data

View File

@ -2,10 +2,13 @@ package com.bonus.imgTool.backstage.service.impl;
import com.bonus.imgTool.backstage.dao.SynthesisQueryDao;
import com.bonus.imgTool.backstage.entity.QueryParamDto;
import com.bonus.imgTool.backstage.entity.SynthesisNumVo;
import com.bonus.imgTool.backstage.entity.SynthesisQueryVo;
import com.bonus.imgTool.backstage.service.SynthesisQueryService;
import com.bonus.imgTool.system.vo.LoginUser;
import com.bonus.imgTool.utils.ServerResponse;
import com.bonus.imgTool.utils.UserUtil;
import com.bonus.imgTool.webResult.Constants;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
@ -14,9 +17,8 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.*;
import java.util.stream.Collectors;
/**
* @className:SynthesisQueryServiceImpl
@ -32,11 +34,30 @@ public class SynthesisQueryServiceImpl implements SynthesisQueryService {
@Resource(name = "SynthesisQueryDao")
private SynthesisQueryDao synthesisQueryDao;
@Override
public ServerResponse getImgNum(QueryParamDto dto) {
try {
String roleLevel = Optional.ofNullable(UserUtil.getLoginUser()).map(LoginUser::getRoleLevel).orElse("0");
String proIds = Optional.ofNullable(UserUtil.getLoginUser()).map(LoginUser::getProIds).orElse("-1");
if(Objects.equals(roleLevel, Constants.ROLE_LEVEL)){ // 项目部级
List<Long> proList = Arrays.stream(proIds.split(",")).map(String::trim).filter(s -> !s.isEmpty()).map(Long::valueOf).collect(Collectors.toList());
dto.setProIds(proList);
}
dto.setRoleLevel(roleLevel);
SynthesisNumVo vo = Optional.ofNullable(synthesisQueryDao.getImgNum(dto)).orElseGet(SynthesisNumVo::new);
return ServerResponse.createSuccess(vo);
} catch (Exception e) {
log.error(e.toString(),e);
return ServerResponse.createErroe("查询失败");
}
}
@Override
public ServerResponse getImgList(QueryParamDto dto) {
PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
try {
dto.setUserId(UserUtil.getLoginUser() != null ? UserUtil.getLoginUser().getId() : 0);
Long userId = Optional.ofNullable(UserUtil.getLoginUser()).map(LoginUser::getId).orElse(0L);
dto.setUserId(userId);
List<SynthesisQueryVo> list = Optional.ofNullable(synthesisQueryDao.getImgList(dto)).orElseGet(ArrayList::new);
PageInfo<SynthesisQueryVo> pageInfo = new PageInfo<>(list);
return ServerResponse.createSuccess(pageInfo);

View File

@ -150,6 +150,16 @@ public class SysUser extends PageEntity {
*/
private String signImg;
/**
* 角色级别
*/
private String roleLevel;
/**
* 工程ID
*/
private String proIds;
public interface Status {
int DISABLED = 0;

View File

@ -42,18 +42,26 @@ public class HighQualityWatermark {
if (opacity < MIN_OPACITY || opacity > MAX_OPACITY) {
opacity = 0.7f;
}
// 读取源图片
BufferedImage sourceImage = ImageIO.read(new File(sourceImagePath));
opacity = Math.max(MIN_OPACITY, Math.min(opacity, MAX_OPACITY));
// 读取原始图片并获取其类型
BufferedImage originalImage = ImageIO.read(new File(sourceImagePath));
int imageType = originalImage.getTransparency() == Transparency.OPAQUE
? BufferedImage.TYPE_INT_RGB
: BufferedImage.TYPE_INT_ARGB;
// 创建与原始图片相同大小的新图像
BufferedImage sourceImage = new BufferedImage(
originalImage.getWidth(),
originalImage.getHeight(),
imageType
);
int imageWidth = sourceImage.getWidth();
int imageHeight = sourceImage.getHeight();
// 创建Graphics2D对象
// 绘制原始图片到新图像
Graphics2D g2d = sourceImage.createGraphics();
g2d.drawImage(originalImage, 0, 0, null);
// 设置最高质量的渲染参数
setHighestQuality(g2d);
// 计算最大允许宽度图片宽度的四分之三
// int maxAllowedWidth = imageWidth / 2;
int maxAllowedWidth = (int) (imageWidth * 3.0 / 4);
@ -309,8 +317,8 @@ public class HighQualityWatermark {
watermarkLines.add(proName.replaceAll("(.{18})", "$1@@"));
watermarkLines.add("安全违章");
watermarkLines.add("违章照片");
String localPath = "L:\\其他\\测试图片\\5.jpg";
String outPath = "L:\\新建文件夹\\output.jpg";
String localPath = "C:\\Users\\10488\\Desktop\\3.jpg";
String outPath = "C:\\Users\\10488\\Desktop\\output.jpg";
// 添加高质量水印
addHighQualityWatermark(localPath, outPath,
watermarkLines, "bottom-left",

View File

@ -182,5 +182,9 @@ public class Constants
public static final Integer TYPE4 = 4;
public static final Integer TRY_COUNT_NUM = 10;
/**角色级别*/
public static final String ROLE_LEVEL = "0";
}

View File

@ -3,18 +3,53 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.imgTool.backstage.dao.SynthesisQueryDao">
<!--综合查询-照片综合查询-照片数量-->
<select id="getImgNum" resultType="com.bonus.imgTool.backstage.entity.SynthesisNumVo">
SELECT COUNT(1) AS totalNum,
COUNT(IF(tcq.upload_type = '1', 1, NULL)) AS safetyVioNum,
COUNT(IF(tcq.upload_type = '2', 1, NULL)) AS qualityInsNum,
COUNT(IF(tcq.upload_type = '3', 1, NULL)) AS safetyMeasNum,
COUNT(IF(tcq.upload_type = '4', 1, NULL)) AS coordinatedPhotoNum,
COUNT(IF(tcq.upload_type = '5', 1, NULL)) AS importIssuesAndPublicityNum
FROM tb_comprehensive_query tcq
LEFT JOIN sys_file_resource sfr ON tcq.id = sfr.source_id AND tcq.upload_type = sfr.upload_type AND sfr.is_active = '1'
WHERE tcq.is_active = '1'
<if test="roleLevel = 0 and proIds != null and proIds.size() > 0">
AND tcq.pro_id IN
<foreach collection="proIds" item="proId" open="(" separator="," close=")">
#{proId}
</foreach>
</if>
GROUP BY tcq.upload_type
</select>
<!--照片综合查询-->
<select id="getImgList" resultType="com.bonus.imgTool.backstage.entity.SynthesisQueryVo">
SELECT id,
'../../img/synthesisQuery/7.jpg' AS originalFilePath,
'../../img/synthesisQuery/7.jpg' AS compressFilePath,
'../../img/synthesisQuery/7.jpg' AS watermarkFilePath,
'1' AS uploadType,
'安全违章' AS uploadTypeName,
operate_time AS uploadTime,
'1' AS sourceType,
'违章照片' AS sourceTypeName,
'0' AS collectStatus
FROM sys_logs
SELECT sfr.id,
sfr.original_file_path AS originalFilePath,
sfr.original_file_path AS compressFilePath,
sfr.original_file_path AS watermarkFilePath,
sfr.upload_type AS uploadType,
CASE sfr.upload_type WHEN '1' THEN '安全违章' WHEN '2' THEN '质量检查' WHEN '3' THEN '安全措施落实'
WHEN '4' THEN '协调照片' WHEN '5' THEN '重要事项及宣传类' ELSE '' END AS uploadTypeName,
sfr.create_time AS uploadTime,
source_type AS sourceType,
sd2.dict_name AS sourceTypeName,
IF(tpc.file_resource_id IS NULL,'0','1') AS collectStatus
FROM tb_comprehensive_query tcq
LEFT JOIN sys_file_resource sfr ON tcq.id = sfr.source_id AND tcq.upload_type = sfr.upload_type AND sfr.is_active = '1'
LEFT JOIN tb_photo_collect tpc ON sfr.id = tpc.file_resource_id AND tpc.collect_user_id = #{userId}
LEFT JOIN sys_distinct sd ON sfr.source_type = sd.dict_value
LEFT JOIN sys_distinct sd2 ON sd.p_id = sd2.id
<where>
<if test="roleLevel = 0 and proIds != null and proIds.size() > 0">
AND tcq.pro_id IN
<foreach collection="proIds" item="proId" open="(" separator="," close=")">
#{proId}
</foreach>
</if>
AND tcq.is_active = '1' AND sd2.dict_value = 'file_source_type'
</where>
ORDER BY sfr.create_time DESC
</select>
</mapper>

View File

@ -75,12 +75,15 @@
<select id="getUser" parameterType="String" resultType="com.bonus.imgTool.model.SysUser">
select t.id,t.user_name as username,t.login_name as loginName,t.org_id as orgId,so.org_name as orgName,
t.password,t.state,t.role_id as roleId,t.login_type loginType,t.new_user newUser,
sr.role_code AS roleCode,sr.role_name AS roleName,t.team_id AS teamId
sr.role_code AS roleCode,sr.role_name AS roleName,t.team_id AS teamId,sr.level AS roleLevel,
GROUP_CONCAT(pro_id) AS proIds
from sys_user t
LEFT JOIN sys_role sr ON t.role_id = sr.role_id AND sr.del_flag = 0
left join sys_org so ON so.org_id = t.org_id and so.del_flag = 0
LEFT JOIN tb_pro_user tpu ON t.id = tpu.user_id
where t.login_name = #{username}
and t.del_flag = 0
GROUP BY t.id
</select>
<select id="getUserCode" parameterType="String" resultType="com.bonus.imgTool.model.SysUser">

View File

@ -11,6 +11,7 @@ layui.config({
flow = layui.flow;
layer = layui.layer;
rightPopup = layui.rightPopup;
initImgNum();
dataFlow();
});

View File

@ -0,0 +1,27 @@
// 获取图片数量
function initImgNum() {
let url = dataUrl + "/backstage/synthesisQuery/getImgNum"
let obj = {}
let params = {
encryptedData: encryptCBC(JSON.stringify(obj))
}
ajaxRequest(url, "POST", params, true, function () {
}, function (result) {
if (result.status === 200) {
setImgNum(result.data);
} else {
layer.msg(result.msg, {icon: 2})
}
}, function (xhr) {
error(xhr)
});
function setImgNum(obj){
$('#totalNum').html(obj.totalNum);
$('#safetyVioNum').html(obj.safetyVioNum);
$('#qualityInsNum').html(obj.qualityInsNum);
$('#safetyMeasNum').html(obj.safetyMeasNum);
$('#coordinatedPhotoNum').html(obj.coordinatedPhotoNum);
$('#importIssuesAndPublicityNum').html(obj.importIssuesAndPublicityNum);
}
}

View File

@ -39,7 +39,7 @@
<div class="type-num layout" onclick="queryByType(this,0)">
<div class="layout">
<p>总照片数</p>
<p>1250</p>
<p id="totalNum">0</p>
</div>
<div class="layout">
<img src="../../img/synthesisQuery/1.png">
@ -48,7 +48,7 @@
<div class="type-num layout" onclick="queryByType(this,1)">
<div class="layout">
<p>安全违章</p>
<p>1250</p>
<p id="safetyVioNum">0</p>
</div>
<div class="layout">
<img src="../../img/synthesisQuery/2.png">
@ -57,7 +57,7 @@
<div class="type-num layout" onclick="queryByType(this,2)">
<div class="layout">
<p>质量检查</p>
<p>1250</p>
<p id="qualityInsNum">0</p>
</div>
<div class="layout">
<img src="../../img/synthesisQuery/3.png">
@ -66,7 +66,7 @@
<div class="type-num layout" onclick="queryByType(this,3)">
<div class="layout">
<p>安全措施落实</p>
<p>1250</p>
<p id="safetyMeasNum">0</p>
</div>
<div class="layout">
<img src="../../img/synthesisQuery/4.png">
@ -75,7 +75,7 @@
<div class="type-num layout" onclick="queryByType(this,4)">
<div class="layout">
<p>协调照片</p>
<p>1250</p>
<p id="coordinatedPhotoNum">0</p>
</div>
<div class="layout">
<img src="../../img/synthesisQuery/5.png">
@ -84,7 +84,7 @@
<div class="type-num layout" onclick="queryByType(this,5)">
<div class="layout">
<p>重要事项及宣传类</p>
<p>1250</p>
<p id="importIssuesAndPublicityNum">0</p>
</div>
<div class="layout">
<img src="../../img/synthesisQuery/6.png">
@ -98,21 +98,10 @@
</div>
<div id="img-box">
<div class="flow-demo layout" id="ID-flow-demo">
<!--<div class="img-info">
<div class="imgData layout">
<img src="../../img/synthesisQuery/7.jpg">
</div>
<div class="imgData2 layout">
<p>2024-05-05</p>
<p class="img-color1">安全违章</p>
</div>
<div class="imgData3 layout">
<p>违章照片</p>
</div>
</div>-->
</div>
</div>
</div>
</body>
<script src="../../js/synthesisQuery/synthesisQuery.js" charset="UTF-8" type="text/javascript"></script>
<script src="../../js/synthesisQuery/synthesisQueryAjax.js" charset="UTF-8" type="text/javascript"></script>
</html>