APP接口修改
This commit is contained in:
parent
62d4736b1f
commit
f2ee4035bb
|
|
@ -65,6 +65,10 @@ public class BusinessConstants {
|
|||
* 安全帽设备类型
|
||||
*/
|
||||
public final static String AQM = "aqm";
|
||||
/**
|
||||
* 球机
|
||||
*/
|
||||
public final static String BALL = "ball";
|
||||
/**
|
||||
* 吊装预警设备
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ public class WarnInfoVo {
|
|||
private String base64Url;
|
||||
/**人员姓名*/
|
||||
private String name;
|
||||
/**是否加载图片*/
|
||||
private Boolean isLoad = false;
|
||||
|
||||
/** 班组id */
|
||||
@Excel(name = "班组id")
|
||||
|
|
|
|||
|
|
@ -1,15 +1,21 @@
|
|||
package com.bonus.bracelet.controller;
|
||||
|
||||
import com.bonus.bracelet.service.IConsControlService;
|
||||
import com.bonus.common.core.constant.BusinessConstants;
|
||||
import com.bonus.common.core.text.Convert;
|
||||
import com.bonus.common.core.utils.ServletUtils;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
import com.bonus.common.entity.app.vo.JdConfigVo;
|
||||
import com.bonus.common.entity.bracelet.BraceletParamsDto;
|
||||
import com.bonus.common.entity.bracelet.vo.CheckConfigVo;
|
||||
import com.bonus.common.entity.bracelet.vo.EquipmentReqVo;
|
||||
import com.bonus.common.entity.bracelet.vo.WarnInfoVo;
|
||||
import com.bonus.common.log.annotation.SysLog;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -46,10 +52,8 @@ public class ConsControlController extends BaseController {
|
|||
* @date 2024/8/8 17:58
|
||||
*/
|
||||
@GetMapping("getBallWarnLists")
|
||||
public TableDataInfo getBallWarnLists(BraceletParamsDto dto){
|
||||
startPage();
|
||||
List<WarnInfoVo> list = service.getBallWarnLists(dto);
|
||||
return getDataTable(list);
|
||||
public AjaxResult getBallWarnLists(BraceletParamsDto dto){
|
||||
return service.getBallWarnLists(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -60,10 +64,12 @@ public class ConsControlController extends BaseController {
|
|||
* @date 2024/8/9 9:42
|
||||
*/
|
||||
@GetMapping("getWarnLists")
|
||||
public TableDataInfo getWarnLists(BraceletParamsDto dto){
|
||||
startPage();
|
||||
List<WarnInfoVo> list = service.getWarnLists(dto);
|
||||
return getDataTable(list);
|
||||
public AjaxResult getWarnLists(BraceletParamsDto dto){
|
||||
Integer pageNum = Convert.toInt(ServletUtils.getParameter(BusinessConstants.PAGE_NUM), 1);
|
||||
Integer pageSize = Convert.toInt(ServletUtils.getParameter(BusinessConstants.PAGE_SIZE), 10);
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
PageInfo<WarnInfoVo> pageInfo = service.getWarnLists(dto);
|
||||
return AjaxResult.success(pageInfo.getList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -216,4 +222,16 @@ public class ConsControlController extends BaseController {
|
|||
public AjaxResult getConfigJdDevice(BraceletParamsDto dto){
|
||||
return service.getConfigJdDevice(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据文件ID获取照片
|
||||
* @param dto
|
||||
* @return AjaxResult
|
||||
* @author cwchen
|
||||
* @date 2024/8/22 10:01
|
||||
*/
|
||||
@PostMapping("getPhotosById")
|
||||
public AjaxResult getPhotosById(@RequestBody BraceletParamsDto dto) {
|
||||
return service.getPhotosById(dto);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.bonus.common.entity.app.vo.JdConfigVo;
|
|||
import com.bonus.common.entity.bracelet.BraceletParamsDto;
|
||||
import com.bonus.common.entity.bracelet.vo.CheckConfigVo;
|
||||
import com.bonus.common.entity.bracelet.vo.WarnInfoVo;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -32,7 +33,7 @@ public interface IConsControlService {
|
|||
* @author cwchen
|
||||
* @date 2024/8/8 17:58
|
||||
*/
|
||||
List<WarnInfoVo> getBallWarnLists(BraceletParamsDto dto);
|
||||
AjaxResult getBallWarnLists(BraceletParamsDto dto);
|
||||
|
||||
/**
|
||||
* 预警信息
|
||||
|
|
@ -41,7 +42,7 @@ public interface IConsControlService {
|
|||
* @author cwchen
|
||||
* @date 2024/8/9 9:44
|
||||
*/
|
||||
List<WarnInfoVo> getWarnLists(BraceletParamsDto dto);
|
||||
PageInfo<WarnInfoVo> getWarnLists(BraceletParamsDto dto);
|
||||
|
||||
/**
|
||||
* 人员管控-人员树
|
||||
|
|
@ -168,4 +169,13 @@ public interface IConsControlService {
|
|||
* @date 2024/8/18 18:02
|
||||
*/
|
||||
AjaxResult getConfigJdDevice(BraceletParamsDto dto);
|
||||
|
||||
/**
|
||||
* 根据文件ID获取照片
|
||||
* @param dto
|
||||
* @return AjaxResult
|
||||
* @author cwchen
|
||||
* @date 2024/8/22 10:01
|
||||
*/
|
||||
AjaxResult getPhotosById(BraceletParamsDto dto);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.bonus.common.entity.bracelet.vo.*;
|
|||
import com.bonus.common.security.utils.ValidatorsUtils;
|
||||
import com.bonus.system.api.RemoteFileService;
|
||||
import com.bonus.system.api.domain.SysFile;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
@ -32,6 +33,8 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @className:ConsControlServiceImpl
|
||||
|
|
@ -78,18 +81,54 @@ public class ConsControlServiceImpl implements IConsControlService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<WarnInfoVo> getBallWarnLists(BraceletParamsDto dto) {
|
||||
List<WarnInfoVo> warnInfoVoList = new ArrayList<>();
|
||||
public AjaxResult getBallWarnLists(BraceletParamsDto dto) {
|
||||
List<List<WarnInfoVo>> dataList = new ArrayList<>();
|
||||
try {
|
||||
warnInfoVoList = mapper.getBallWarnLists(dto);
|
||||
for (WarnInfoVo vo : warnInfoVoList) {
|
||||
String imgBase64 = getImgBase64(vo.getBase64Url());
|
||||
vo.setBase64Url(imgBase64);
|
||||
// 设备类型设置为球机
|
||||
dto.setDevType(BusinessConstants.BALL);
|
||||
List<WarnInfoVo> warnInfoVoList = mapper.getBallWarnLists(dto);
|
||||
if(CollectionUtils.isNotEmpty(warnInfoVoList)){
|
||||
for (int i = 0; i < warnInfoVoList.size(); i++) {
|
||||
WarnInfoVo warnInfoVo = warnInfoVoList.get(i);
|
||||
if(StringUtils.isEmpty(warnInfoVo.getBase64Url())){
|
||||
warnInfoVo.setBase64Url("66c68c712350293fa1d6b197");
|
||||
}
|
||||
// 前三张违章照片加载图片,其余调用加载
|
||||
if (i < 3) {
|
||||
String imgBase64 = getImgBase64(warnInfoVo.getBase64Url());
|
||||
warnInfoVo.setBase64Url(imgBase64);
|
||||
warnInfoVo.setIsLoad(true);
|
||||
}
|
||||
}
|
||||
dataList = groupList(warnInfoVoList);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return warnInfoVoList;
|
||||
return AjaxResult.success(dataList);
|
||||
}
|
||||
|
||||
private static final Integer MAX_NUMBER = 3;
|
||||
|
||||
/**
|
||||
* 计算切分次数
|
||||
*/
|
||||
private static Integer countStep(Integer size) {
|
||||
return (size + MAX_NUMBER - 1) / MAX_NUMBER;
|
||||
}
|
||||
|
||||
/**
|
||||
* 切割数组
|
||||
* @param list
|
||||
* @return List<List<WarnInfoVo>>
|
||||
* @author cwchen
|
||||
* @date 2024/8/22 13:31
|
||||
*/
|
||||
public List<List<WarnInfoVo>> groupList(List<WarnInfoVo> list) {
|
||||
List<List<WarnInfoVo>> dataList = new ArrayList<>();
|
||||
int limit = countStep(list.size());
|
||||
dataList = Stream.iterate(0, n -> n + 1).limit(limit).parallel().map(a -> list.stream().skip(a * MAX_NUMBER).limit(MAX_NUMBER).parallel().collect(Collectors.toList())).collect(Collectors.toList());
|
||||
return dataList;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -116,14 +155,17 @@ public class ConsControlServiceImpl implements IConsControlService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<WarnInfoVo> getWarnLists(BraceletParamsDto dto) {
|
||||
public PageInfo<WarnInfoVo> getWarnLists(BraceletParamsDto dto) {
|
||||
List<WarnInfoVo> warnInfoVoList = new ArrayList<>();
|
||||
try {
|
||||
// 设备类型设置为球机
|
||||
dto.setDevType(BusinessConstants.BALL);
|
||||
warnInfoVoList = mapper.getWarnLists(dto);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return warnInfoVoList;
|
||||
PageInfo<WarnInfoVo> pageInfo = new PageInfo<>(warnInfoVoList);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -273,7 +315,7 @@ public class ConsControlServiceImpl implements IConsControlService {
|
|||
return AjaxResult.error("时间格式错误(HH:MM)");
|
||||
}
|
||||
}
|
||||
if(timeArr.length > 0){
|
||||
if (timeArr.length > 0) {
|
||||
return AjaxResult.error("固定时间验证不能超过时间配置项");
|
||||
}
|
||||
} else if (Objects.equals(vo.getConfigType(), BusinessConstants.CONFIG_TYPE2)) {
|
||||
|
|
@ -478,7 +520,7 @@ public class ConsControlServiceImpl implements IConsControlService {
|
|||
if (CollectionUtils.isEmpty(configItems)) {
|
||||
return AjaxResult.error("配置项不能为空");
|
||||
}
|
||||
if(configItems.size() > 10){
|
||||
if (configItems.size() > 10) {
|
||||
return AjaxResult.error("设备配置项不能超过十个");
|
||||
}
|
||||
Set<JdConfigVo.ConfigItems> itemsHashSet = new HashSet<>(configItems);
|
||||
|
|
@ -505,11 +547,42 @@ public class ConsControlServiceImpl implements IConsControlService {
|
|||
try {
|
||||
list = mapper.getConfigJdDevice(dto);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(),e);
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getPhotosById(BraceletParamsDto dto) {
|
||||
List<String> base64List = new ArrayList<>();
|
||||
List<String> dataName = dto.getDataName();
|
||||
for (String filePath : dataName) {
|
||||
System.err.println(filePath);
|
||||
String imageBase64 = getImageBase64(filePath);
|
||||
base64List.add(imageBase64);
|
||||
}
|
||||
return AjaxResult.success(base64List);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件
|
||||
*
|
||||
* @param filePath
|
||||
* @return String
|
||||
* @author cwchen
|
||||
* @date 2024/8/22 10:02
|
||||
*/
|
||||
public String getImageBase64(String filePath) {
|
||||
R<SysFile> result = remoteFileService.getImgBase64(filePath, SecurityConstants.INNER);
|
||||
if (result != null && result.getCode() == HttpStatus.SUCCESS && result.getData() != null) {
|
||||
String jsonString = JSON.toJSONString(result.getData());
|
||||
JSONObject item = JSON.parseObject(jsonString);
|
||||
String base64 = item.getString("url");
|
||||
return base64;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 赋值手环设备的经纬度
|
||||
*
|
||||
|
|
|
|||
|
|
@ -87,31 +87,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</where>
|
||||
ORDER BY a.orderTime DESC
|
||||
</select>
|
||||
<!--获取球机违章识别内容-获取最新的30条-->
|
||||
<!--获取球机违章识别内容-->
|
||||
<select id="getBallWarnLists" resultType="com.bonus.common.entity.bracelet.vo.WarnInfoVo">
|
||||
SELECT tw.warn_content AS warnContent,
|
||||
tw.warn_time AS warnTime,
|
||||
td.dev_name AS devName,
|
||||
sfs.file_path AS base64Url,
|
||||
tpe.name,
|
||||
sdd.dict_label AS devTypeName,
|
||||
tp.depart_id AS departId
|
||||
sfs.file_path AS base64Url
|
||||
FROM tb_warn tw
|
||||
LEFT JOIN tb_project tp ON tp.id = tw.pro_id AND tp.del_flag = 0
|
||||
LEFT JOIN tb_device td ON tw.dev_id = td.id AND td.del_flag = 0
|
||||
LEFT JOIN tb_device td ON tw.dev_id = td.id AND td.del_flag = 0 AND td.dev_type = #{devType}
|
||||
LEFT JOIN sys_file_source sfs ON tw.id = sfs.source_id AND sfs.source_type = 8 AND sfs.del_flag = 0
|
||||
LEFT JOIN tb_people tpe ON tpe.id = tw.user_id AND tpe.del_flag = 0
|
||||
LEFT JOIN sys_dict_data sdd ON td.dev_type = sdd.dict_value AND sdd.dict_type = 'sys_device_type'
|
||||
<where>
|
||||
LEFT JOIN tb_project tp ON tp.id = tw.pro_id AND tp.del_flag = 0
|
||||
WHERE tw.dev_type = 1 AND tw.warn_type = 2
|
||||
<if test="roleCode!='administrators' and roleCode!='depart'">
|
||||
tp.depart_id = -1
|
||||
AND tp.depart_id = -1
|
||||
</if>
|
||||
<if test="roleCode=='depart'">
|
||||
AND tp.depart_id = #{departId}
|
||||
</if>
|
||||
AND tp.depart_id IS NOT NULL
|
||||
AND tw.warn_type = 2
|
||||
</where>
|
||||
ORDER BY tw.create_time DESC
|
||||
</select>
|
||||
<!--预警信息-->
|
||||
|
|
@ -125,16 +118,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
LEFT JOIN tb_project tp ON tp.id = tw.pro_id AND tp.del_flag = 0
|
||||
LEFT JOIN tb_device td ON tw.dev_id = td.id AND td.del_flag = 0
|
||||
LEFT JOIN sys_dict_data sdd ON td.dev_type = sdd.dict_value AND sdd.dict_type = 'sys_device_type'
|
||||
<where>
|
||||
<if test="roleCode!='administrators' and roleCode!='depart'">
|
||||
tp.depart_id = -1
|
||||
</if>
|
||||
<if test="roleCode=='depart'">
|
||||
AND tp.depart_id = #{departId}
|
||||
</if>
|
||||
AND tp.depart_id IS NOT NULL
|
||||
</where>
|
||||
ORDER BY tw.create_time DESC
|
||||
WHERE tw.dev_type = 1 AND tw.warn_type = 2
|
||||
<if test="roleCode!='administrators' and roleCode!='depart'">
|
||||
AND tp.depart_id = -1
|
||||
</if>
|
||||
<if test="roleCode=='depart'">
|
||||
AND tp.depart_id = #{departId}
|
||||
</if>
|
||||
AND tp.depart_id IS NOT NULL
|
||||
ORDER BY tw.warn_time
|
||||
</select>
|
||||
<!--人员管控-人员树-->
|
||||
<select id="getPersonsTree" resultType="com.bonus.common.entity.bracelet.vo.PersonTreeVo">
|
||||
|
|
|
|||
Loading…
Reference in New Issue