[add] 新增AI工单等级设置,工单等级与岗位关联,斯巴达识别获取token接口
This commit is contained in:
@ -49,9 +49,9 @@ spring:
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
||||
url: jdbc:mysql://192.168.110.119:3306/xinnengyuan?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: 123456
|
||||
url: jdbc:mysql://192.168.110.2:13386/xinnengyuandev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: xinnengyuandev
|
||||
password: StRWCZdZirysNSs2
|
||||
# # 从库数据源
|
||||
# slave:
|
||||
# lazy: true
|
||||
@ -278,3 +278,8 @@ ys7:
|
||||
#ys7:
|
||||
# app-key: f01490bd5d5241b7809d8fc5fe84f7f8
|
||||
# app-secret: d468f270699de855fd85fe7fd6f9595f
|
||||
# 斯巴达算法
|
||||
sparta:
|
||||
url: http://119.3.204.120:8040
|
||||
client-id: test
|
||||
client-secret: 115fcb08fa6742a1b086d9bb80a6ad59
|
||||
|
@ -267,10 +267,10 @@ justauth:
|
||||
redirect-uri: ${justauth.address}/social-callback?source=gitlab
|
||||
# 和风天气 https://dev.qweather.com/
|
||||
weather:
|
||||
key-id: T65EAABUXC
|
||||
project-id: 2JTHPUQ5YY
|
||||
private-key: MC4CAQAwBQYDK2VwBCIEIMAglX7IsxYiTeM+FXXnvCUsIggajeP4s8gAllewm6BN
|
||||
api-host: n35rk53njv.re.qweatherapi.com
|
||||
key-id: xx
|
||||
project-id: xx
|
||||
private-key: xx
|
||||
api-host: xx
|
||||
# dxf转 geojson 执行文件名
|
||||
dxf2GeoJson:
|
||||
file-name: main
|
||||
|
@ -0,0 +1,25 @@
|
||||
package org.dromara.test;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.manager.spartamanager.SpartaManager;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
/**
|
||||
* @author lcj
|
||||
* @date 2025/6/20 19:40
|
||||
*/
|
||||
@Slf4j
|
||||
@SpringBootTest
|
||||
public class SpartaTest {
|
||||
|
||||
@Resource
|
||||
private SpartaManager spartaManager;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
String token = spartaManager.getToken();
|
||||
log.info("token: {}", token);
|
||||
}
|
||||
}
|
@ -28,6 +28,11 @@ public interface FacRedisKeyConstant {
|
||||
*/
|
||||
String GEO_TYPE_NAME = "name";
|
||||
|
||||
/**
|
||||
* 设施模块位置 GIS Redis 缓存前缀
|
||||
*/
|
||||
String POSITION_GIS_REDIS_KEY_PREFIX = FAC_REDIS_PREFIX + "gis:" + "position:";
|
||||
|
||||
/**
|
||||
* 批量上传桩点、支架、立柱 Redis 缓存 key
|
||||
*
|
||||
|
@ -13,10 +13,7 @@ import org.dromara.other.service.IOthYs7DeviceService;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
@ -29,7 +26,7 @@ import java.util.stream.Collectors;
|
||||
* @date 2025/6/18 15:59
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
//@Component
|
||||
public class IncSyncYs7DeviceCapturePicData {
|
||||
|
||||
@Resource
|
||||
@ -98,6 +95,7 @@ public class IncSyncYs7DeviceCapturePicData {
|
||||
// 抓取当前画面图片
|
||||
try {
|
||||
String url = ys7Manager.getCaptureDevicePic(deviceSerial, channelNo, 2);
|
||||
img.setCreateTime(new Date());
|
||||
img.setUrl(url);
|
||||
imgList.add(img);
|
||||
} catch (Exception e) {
|
||||
@ -111,6 +109,7 @@ public class IncSyncYs7DeviceCapturePicData {
|
||||
img.setDeviceName(ys7Device.getDeviceName());
|
||||
try {
|
||||
String url = ys7Manager.getCaptureDevicePic(deviceSerial, 1, 2);
|
||||
img.setCreateTime(new Date());
|
||||
img.setUrl(url);
|
||||
imgList.add(img);
|
||||
} catch (Exception e) {
|
||||
|
@ -0,0 +1,24 @@
|
||||
package org.dromara.manager.spartamanager;
|
||||
|
||||
/**
|
||||
* @author lcj
|
||||
* @date 2025/6/20 19:05
|
||||
*/
|
||||
public interface SpartaConstant {
|
||||
|
||||
/**
|
||||
* token redis 缓存 key 前缀
|
||||
*/
|
||||
String TOKEN_REDIS_KEY = "sparta:token";
|
||||
|
||||
/**
|
||||
* 获取 token api 路径
|
||||
*/
|
||||
String GET_TOKEN_API_PATH_GET = "/token";
|
||||
|
||||
/**
|
||||
* 识别 api 路径
|
||||
*/
|
||||
String RECOGNIZE_API_PATH_GET = "/api/recognize";
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package org.dromara.manager.spartamanager;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.manager.spartamanager.vo.SpartaTokenVo;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author lcj
|
||||
* @date 2025/6/20 19:27
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SpartaManager {
|
||||
|
||||
@Resource
|
||||
private SpartaProperties spartaProperties;
|
||||
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
/**
|
||||
* 获取token
|
||||
*
|
||||
* @return token
|
||||
*/
|
||||
public String getToken() {
|
||||
String token = stringRedisTemplate.opsForValue().get(SpartaConstant.TOKEN_REDIS_KEY);
|
||||
if (token != null) {
|
||||
return token;
|
||||
}
|
||||
SpartaTokenVo tokenVo = SpartaRequestUtils.getToken(
|
||||
spartaProperties.getUrl(),
|
||||
spartaProperties.getClientId(),
|
||||
spartaProperties.getClientSecret()
|
||||
);
|
||||
token = tokenVo.getToken();
|
||||
Long expiresAt = tokenVo.getExpiresAt();
|
||||
stringRedisTemplate.opsForValue().set(SpartaConstant.TOKEN_REDIS_KEY, token, (expiresAt - 3600), TimeUnit.SECONDS);
|
||||
return token;
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package org.dromara.manager.spartamanager;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author lcj
|
||||
* @date 2025/6/20 19:01
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "sparta")
|
||||
public class SpartaProperties {
|
||||
|
||||
/**
|
||||
* 请求地址
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 客户端id
|
||||
*/
|
||||
private String clientId;
|
||||
|
||||
/**
|
||||
* 客户端密钥
|
||||
*/
|
||||
private String clientSecret;
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package org.dromara.manager.spartamanager;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.manager.spartamanager.vo.SpartaResponseVo;
|
||||
import org.dromara.manager.spartamanager.vo.SpartaTokenVo;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @author lcj
|
||||
* @date 2025/6/20 19:06
|
||||
*/
|
||||
@Slf4j
|
||||
public class SpartaRequestUtils {
|
||||
|
||||
/**
|
||||
* 获取斯巴达 Token
|
||||
*
|
||||
* @param host 域名
|
||||
* @param clientId 客户端id
|
||||
* @param clientSecret 客户端密钥
|
||||
* @return token
|
||||
*/
|
||||
public static SpartaTokenVo getToken(String host, String clientId, String clientSecret) {
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("clientId", clientId);
|
||||
paramMap.put("clientSecret", clientSecret);
|
||||
String errorMsg = "斯巴达 Token 请求失败";
|
||||
String url = host + SpartaConstant.GET_TOKEN_API_PATH_GET;
|
||||
try (HttpResponse response = HttpRequest.get(url)
|
||||
.form(paramMap)
|
||||
.execute()) {
|
||||
if (!response.isOk()) {
|
||||
log.error("{}:{}", errorMsg, response.getStatus());
|
||||
throw new ServiceException(errorMsg + response.getStatus());
|
||||
}
|
||||
String body = response.body();
|
||||
if (body == null) {
|
||||
log.error("{}:{}", errorMsg, "返回参数为空");
|
||||
}
|
||||
log.info("斯巴达 Token 请求成功:{}", body);
|
||||
JSONObject jsonObject = JSONUtil.parseObj(body);
|
||||
SpartaTokenVo tokenVo = new SpartaTokenVo();
|
||||
tokenVo.setToken(jsonObject.get("token", String.class));
|
||||
tokenVo.setExpiresAt(jsonObject.get("expires_at", Long.class));
|
||||
return tokenVo;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package org.dromara.manager.spartamanager.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author lcj
|
||||
* @date 2025/6/20 19:25
|
||||
*/
|
||||
@Data
|
||||
public class SpartaResponseVo {
|
||||
|
||||
/**
|
||||
* 响应码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 响应数据
|
||||
*/
|
||||
private String data;
|
||||
|
||||
/**
|
||||
* 响应信息
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package org.dromara.manager.spartamanager.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author lcj
|
||||
* @date 2025/6/20 19:36
|
||||
*/
|
||||
@Data
|
||||
public class SpartaTokenVo {
|
||||
|
||||
/**
|
||||
* token
|
||||
*/
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* 过期时间
|
||||
*/
|
||||
private Long expiresAt;
|
||||
}
|
@ -54,11 +54,11 @@ public class Ys7Manager {
|
||||
*/
|
||||
public String getToken() {
|
||||
String tokenRedisKey = Ys7Constant.TOKEN_REDIS_KEY;
|
||||
String token = stringRedisTemplate.opsForValue().get(tokenRedisKey);
|
||||
// 不为空,直接返回 token
|
||||
if (token != null) {
|
||||
return token;
|
||||
}
|
||||
String token = stringRedisTemplate.opsForValue().get(tokenRedisKey);
|
||||
// 不为空,直接返回 token
|
||||
if (token != null) {
|
||||
return token;
|
||||
}
|
||||
// 向云服务商请求新的 token
|
||||
String newToken = Ys7RequestUtils.getToken(ys7Properties.getAppKey(), ys7Properties.getAppSecret());
|
||||
// 设置有效期
|
||||
|
@ -45,7 +45,7 @@ public class Ys7RequestUtils {
|
||||
String body = response.body();
|
||||
Ys7ResponseVo responseVo = JSONUtil.toBean(body, Ys7ResponseVo.class);
|
||||
if (!responseVo.getCode().equals("200")) {
|
||||
log.error("{},状态码:{},:{}", errorMsg, responseVo.getCode(), responseVo.getMsg());
|
||||
log.error("{},状态码:{},{}", errorMsg, responseVo.getCode(), responseVo.getMsg());
|
||||
throw new ServiceException(errorMsg + responseVo.getMsg());
|
||||
}
|
||||
log.info("Ys7 Token 请求成功:{}", body);
|
||||
@ -85,7 +85,7 @@ public class Ys7RequestUtils {
|
||||
String body = response.body();
|
||||
Ys7PageResponseVo responseVo = JSONUtil.toBean(body, Ys7PageResponseVo.class);
|
||||
if (!responseVo.getCode().equals("200")) {
|
||||
log.error("{},状态码:{},:{}", errorMsg, responseVo.getCode(), responseVo.getMsg());
|
||||
log.error("{},状态码:{},{}", errorMsg, responseVo.getCode(), responseVo.getMsg());
|
||||
throw new ServiceException(errorMsg + responseVo.getMsg());
|
||||
}
|
||||
log.info("Ys7 分页查询设备列表 第{}页大小{} 响应数据:{}", pageStart, pageSize, responseVo.getData());
|
||||
@ -127,7 +127,7 @@ public class Ys7RequestUtils {
|
||||
String body = response.body();
|
||||
Ys7NoDataResponseVo responseVo = JSONUtil.toBean(body, Ys7NoDataResponseVo.class);
|
||||
if (!responseVo.getCode().equals("200")) {
|
||||
log.error("{},状态码:{},:{}", errorMsg, responseVo.getCode(), responseVo.getMsg());
|
||||
log.error("{},状态码:{},{}", errorMsg, responseVo.getCode(), responseVo.getMsg());
|
||||
throw new ServiceException(errorMsg + responseVo.getMsg());
|
||||
}
|
||||
log.info("修改设备名称请求成功,设备 {} 名称修改为 {}", deviceSerial, deviceName);
|
||||
@ -162,7 +162,7 @@ public class Ys7RequestUtils {
|
||||
String body = response.body();
|
||||
Ys7ResponseVo responseVo = JSONUtil.toBean(body, Ys7ResponseVo.class);
|
||||
if (!responseVo.getCode().equals("200")) {
|
||||
log.error("{},状态码:{},:{}", errorMsg, responseVo.getCode(), responseVo.getMsg());
|
||||
log.error("{},状态码:{},{}", errorMsg, responseVo.getCode(), responseVo.getMsg());
|
||||
throw new ServiceException(errorMsg + responseVo.getMsg());
|
||||
}
|
||||
// 获取 data 中的 index
|
||||
@ -204,7 +204,7 @@ public class Ys7RequestUtils {
|
||||
String body = response.body();
|
||||
Ys7NoDataResponseVo responseVo = JSONUtil.toBean(body, Ys7NoDataResponseVo.class);
|
||||
if (!responseVo.getCode().equals("200")) {
|
||||
log.error("{},状态码:{},:{}", errorMsg, responseVo.getCode(), responseVo.getMsg());
|
||||
log.error("{},状态码:{},{}", errorMsg, responseVo.getCode(), responseVo.getMsg());
|
||||
throw new ServiceException(errorMsg + responseVo.getMsg());
|
||||
}
|
||||
log.info("调用设备预置点请求成功,设备 {} 调用预置点成功,通道:{},序号 {}", deviceSerial, channelNo, index);
|
||||
@ -241,7 +241,7 @@ public class Ys7RequestUtils {
|
||||
String body = response.body();
|
||||
Ys7NoDataResponseVo responseVo = JSONUtil.toBean(body, Ys7NoDataResponseVo.class);
|
||||
if (!responseVo.getCode().equals("200")) {
|
||||
log.error("{},状态码:{},:{}", errorMsg, responseVo.getCode(), responseVo.getMsg());
|
||||
log.error("{},状态码:{},{}", errorMsg, responseVo.getCode(), responseVo.getMsg());
|
||||
throw new ServiceException(errorMsg + responseVo.getMsg());
|
||||
}
|
||||
log.info("删除设备预置点请求成功,设备 {} 删除预置点成功,通道:{},序号 {}", deviceSerial, channelNo, index);
|
||||
@ -281,7 +281,7 @@ public class Ys7RequestUtils {
|
||||
String body = response.body();
|
||||
Ys7ResponseVo responseVo = JSONUtil.toBean(body, Ys7ResponseVo.class);
|
||||
if (!responseVo.getCode().equals("200")) {
|
||||
log.error("{},状态码:{},:{}", errorMsg, responseVo.getCode(), responseVo.getMsg());
|
||||
log.error("{},状态码:{},{}", errorMsg, responseVo.getCode(), responseVo.getMsg());
|
||||
throw new ServiceException(errorMsg + responseVo.getMsg());
|
||||
}
|
||||
String data = responseVo.getData();
|
||||
|
@ -4,6 +4,7 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author lcj
|
||||
@ -30,4 +31,9 @@ public class OthYs7DeviceImgCreateByCapture implements Serializable {
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 图片创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
|
@ -174,6 +174,7 @@ public class OthYs7DeviceImgServiceImpl extends ServiceImpl<OthYs7DeviceImgMappe
|
||||
String ossUrl = uploadVo.getUrl();
|
||||
if (StringUtils.isNotBlank(ossUrl)) {
|
||||
othYs7DeviceImg.setDeviceSerial(deviceSerial);
|
||||
othYs7DeviceImg.setCreateTime(img.getCreateTime());
|
||||
othYs7DeviceImg.setDeviceName(img.getDeviceName());
|
||||
othYs7DeviceImg.setUrl(ossUrl);
|
||||
saveList.add(othYs7DeviceImg);
|
||||
|
@ -0,0 +1,107 @@
|
||||
package org.dromara.safety.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.safety.domain.dto.violationlevel.HseViolationLevelCreateReq;
|
||||
import org.dromara.safety.domain.dto.violationlevel.HseViolationLevelQueryReq;
|
||||
import org.dromara.safety.domain.dto.violationlevel.HseViolationLevelUpdateReq;
|
||||
import org.dromara.safety.domain.vo.violationlevel.HseViolationLevelByPostVo;
|
||||
import org.dromara.safety.domain.vo.violationlevel.HseViolationLevelVo;
|
||||
import org.dromara.safety.service.IHseViolationLevelService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 违章等级
|
||||
*
|
||||
* @author lcj
|
||||
* @date 2025-06-20
|
||||
*/
|
||||
@Validated
|
||||
@RestController
|
||||
@RequestMapping("/safety/violationLevel")
|
||||
public class HseViolationLevelController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private IHseViolationLevelService hseViolationLevelService;
|
||||
|
||||
/**
|
||||
* 查询违章等级列表
|
||||
*/
|
||||
@SaCheckPermission("safety:violationLevel:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<HseViolationLevelVo> list(HseViolationLevelQueryReq req, PageQuery pageQuery) {
|
||||
return hseViolationLevelService.queryPageList(req, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出违章等级列表
|
||||
*/
|
||||
@SaCheckPermission("safety:violationLevel:export")
|
||||
@Log(title = "违章等级", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HseViolationLevelQueryReq req, HttpServletResponse response) {
|
||||
List<HseViolationLevelVo> list = hseViolationLevelService.queryList(req);
|
||||
ExcelUtil.exportExcel(list, "违章等级", HseViolationLevelVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取违章等级详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("safety:violationLevel:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<HseViolationLevelByPostVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(hseViolationLevelService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增违章等级
|
||||
*/
|
||||
@SaCheckPermission("safety:violationLevel:add")
|
||||
@Log(title = "违章等级", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Long> add(@Validated @RequestBody HseViolationLevelCreateReq req) {
|
||||
return R.ok(hseViolationLevelService.insertByBo(req));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改违章等级
|
||||
*/
|
||||
@SaCheckPermission("safety:violationLevel:edit")
|
||||
@Log(title = "违章等级", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated @RequestBody HseViolationLevelUpdateReq req) {
|
||||
return toAjax(hseViolationLevelService.updateByBo(req));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除违章等级
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("safety:violationLevel:remove")
|
||||
@Log(title = "违章等级", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(hseViolationLevelService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package org.dromara.safety.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 违章等级对象 hse_violation_level
|
||||
*
|
||||
* @author lcj
|
||||
* @date 2025-06-20
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("hse_violation_level")
|
||||
public class HseViolationLevel extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 违章等级
|
||||
*/
|
||||
private String violationLevel;
|
||||
|
||||
/**
|
||||
* 颜色
|
||||
*/
|
||||
private String color;
|
||||
|
||||
/**
|
||||
* 风险等级
|
||||
*/
|
||||
private String riskType;
|
||||
|
||||
/**
|
||||
* 违章类型(多个逗号分隔)
|
||||
*/
|
||||
private String violationType;
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package org.dromara.safety.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 等级与岗位关联对象 hse_violation_level_post
|
||||
*
|
||||
* @author lcj
|
||||
* @date 2025-06-20
|
||||
*/
|
||||
@Data
|
||||
@TableName("hse_violation_level_post")
|
||||
public class HseViolationLevelPost implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 等级
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
private Long level;
|
||||
|
||||
/**
|
||||
* 岗位
|
||||
*/
|
||||
private Long post;
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package org.dromara.safety.domain.dto.violationlevel;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lcj
|
||||
* @date 2025/6/20 11:17
|
||||
*/
|
||||
@Data
|
||||
public class HseViolationLevelCreateReq implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = -4225755294412571262L;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
@NotNull(message = "项目id不能为空")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 违章等级
|
||||
*/
|
||||
@NotNull(message = "违章等级不能为空")
|
||||
private String violationLevel;
|
||||
|
||||
/**
|
||||
* 颜色
|
||||
*/
|
||||
private String color;
|
||||
|
||||
/**
|
||||
* 风险等级
|
||||
*/
|
||||
private String riskType;
|
||||
|
||||
/**
|
||||
* 岗位
|
||||
*/
|
||||
@NotNull(message = "岗位不能为空")
|
||||
private List<Long> postIdList;
|
||||
|
||||
/**
|
||||
* 违章类型(多个逗号分隔)
|
||||
*/
|
||||
private String violationType;
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package org.dromara.safety.domain.dto.violationlevel;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author lcj
|
||||
* @date 2025/6/20 11:17
|
||||
*/
|
||||
@Data
|
||||
public class HseViolationLevelQueryReq implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = -988722207116292047L;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 违章等级
|
||||
*/
|
||||
private String violationLevel;
|
||||
|
||||
/**
|
||||
* 风险等级
|
||||
*/
|
||||
private String riskType;
|
||||
|
||||
/**
|
||||
* 违章类型(多个逗号分隔)
|
||||
*/
|
||||
private String violationType;
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package org.dromara.safety.domain.dto.violationlevel;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lcj
|
||||
* @date 2025/6/20 11:18
|
||||
*/
|
||||
@Data
|
||||
public class HseViolationLevelUpdateReq implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = -5859829053886378192L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@NotNull(message = "主键id不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 违章等级
|
||||
*/
|
||||
private String violationLevel;
|
||||
|
||||
/**
|
||||
* 颜色
|
||||
*/
|
||||
private String color;
|
||||
|
||||
/**
|
||||
* 风险等级
|
||||
*/
|
||||
private String riskType;
|
||||
|
||||
/**
|
||||
* 岗位
|
||||
*/
|
||||
private List<Long> postIdList;
|
||||
|
||||
/**
|
||||
* 违章类型(多个逗号分隔)
|
||||
*/
|
||||
private String violationType;
|
||||
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package org.dromara.safety.domain.vo.violationlevel;
|
||||
|
||||
import lombok.Data;
|
||||
import org.dromara.system.domain.vo.SysPostVo;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lcj
|
||||
* @date 2025/6/20 14:22
|
||||
*/
|
||||
@Data
|
||||
public class HseViolationLevelByPostVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = -5927532440663249467L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 违章等级
|
||||
*/
|
||||
private String violationLevel;
|
||||
|
||||
/**
|
||||
* 颜色
|
||||
*/
|
||||
private String color;
|
||||
|
||||
/**
|
||||
* 风险等级
|
||||
*/
|
||||
private String riskType;
|
||||
|
||||
/**
|
||||
* 违章类型(多个逗号分隔)
|
||||
*/
|
||||
private String violationType;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 岗位
|
||||
*/
|
||||
private List<SysPostVo> postList;
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package org.dromara.safety.domain.vo.violationlevel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import org.dromara.safety.domain.HseViolationLevel;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 违章等级视图对象 hse_violation_level
|
||||
*
|
||||
* @author lcj
|
||||
* @date 2025-06-20
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = HseViolationLevel.class)
|
||||
public class HseViolationLevelVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@ExcelProperty(value = "主键id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
@ExcelProperty(value = "项目id")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 违章等级
|
||||
*/
|
||||
@ExcelProperty(value = "违章等级")
|
||||
private String violationLevel;
|
||||
|
||||
/**
|
||||
* 颜色
|
||||
*/
|
||||
@ExcelProperty(value = "颜色")
|
||||
private String color;
|
||||
|
||||
/**
|
||||
* 风险等级
|
||||
*/
|
||||
@ExcelProperty(value = "风险等级", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(dictType = "risk_level_type")
|
||||
private String riskType;
|
||||
|
||||
/**
|
||||
* 违章类型(多个逗号分隔)
|
||||
*/
|
||||
@ExcelProperty(value = "违章类型", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(dictType = "violation_level_type")
|
||||
private String violationType;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ExcelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package org.dromara.safety.domain.vo.violationlevelpost;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.dromara.safety.domain.HseViolationLevelPost;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* 等级与岗位关联视图对象 hse_violation_level_post
|
||||
*
|
||||
* @author lcj
|
||||
* @date 2025-06-20
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = HseViolationLevelPost.class)
|
||||
public class HseViolationLevelPostVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 等级
|
||||
*/
|
||||
@ExcelProperty(value = "等级")
|
||||
private Long level;
|
||||
|
||||
/**
|
||||
* 岗位
|
||||
*/
|
||||
@ExcelProperty(value = "岗位")
|
||||
private Long post;
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package org.dromara.safety.mapper;
|
||||
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.safety.domain.HseViolationLevel;
|
||||
import org.dromara.safety.domain.vo.violationlevel.HseViolationLevelVo;
|
||||
|
||||
/**
|
||||
* 违章等级Mapper接口
|
||||
*
|
||||
* @author lcj
|
||||
* @date 2025-06-20
|
||||
*/
|
||||
public interface HseViolationLevelMapper extends BaseMapperPlus<HseViolationLevel, HseViolationLevelVo> {
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package org.dromara.safety.mapper;
|
||||
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.safety.domain.HseViolationLevelPost;
|
||||
import org.dromara.safety.domain.vo.violationlevelpost.HseViolationLevelPostVo;
|
||||
|
||||
/**
|
||||
* 等级与岗位关联Mapper接口
|
||||
*
|
||||
* @author lcj
|
||||
* @date 2025-06-20
|
||||
*/
|
||||
public interface HseViolationLevelPostMapper extends BaseMapperPlus<HseViolationLevelPost, HseViolationLevelPostVo> {
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package org.dromara.safety.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.dromara.safety.domain.HseViolationLevelPost;
|
||||
|
||||
/**
|
||||
* 等级与岗位关联Service接口
|
||||
*
|
||||
* @author lcj
|
||||
* @date 2025-06-20
|
||||
*/
|
||||
public interface IHseViolationLevelPostService extends IService<HseViolationLevelPost> {
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
package org.dromara.safety.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.safety.domain.HseViolationLevel;
|
||||
import org.dromara.safety.domain.dto.violationlevel.HseViolationLevelCreateReq;
|
||||
import org.dromara.safety.domain.dto.violationlevel.HseViolationLevelQueryReq;
|
||||
import org.dromara.safety.domain.dto.violationlevel.HseViolationLevelUpdateReq;
|
||||
import org.dromara.safety.domain.vo.violationlevel.HseViolationLevelByPostVo;
|
||||
import org.dromara.safety.domain.vo.violationlevel.HseViolationLevelVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 违章等级Service接口
|
||||
*
|
||||
* @author lcj
|
||||
* @date 2025-06-20
|
||||
*/
|
||||
public interface IHseViolationLevelService extends IService<HseViolationLevel> {
|
||||
|
||||
/**
|
||||
* 查询违章等级
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 违章等级
|
||||
*/
|
||||
HseViolationLevelByPostVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询违章等级列表
|
||||
*
|
||||
* @param req 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 违章等级分页列表
|
||||
*/
|
||||
TableDataInfo<HseViolationLevelVo> queryPageList(HseViolationLevelQueryReq req, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的违章等级列表
|
||||
*
|
||||
* @param req 查询条件
|
||||
* @return 违章等级列表
|
||||
*/
|
||||
List<HseViolationLevelVo> queryList(HseViolationLevelQueryReq req);
|
||||
|
||||
/**
|
||||
* 新增违章等级
|
||||
*
|
||||
* @param req 违章等级
|
||||
* @return 新增违章等级主键id
|
||||
*/
|
||||
Long insertByBo(HseViolationLevelCreateReq req);
|
||||
|
||||
/**
|
||||
* 修改违章等级
|
||||
*
|
||||
* @param req 违章等级
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(HseViolationLevelUpdateReq req);
|
||||
|
||||
/**
|
||||
* 校验并批量删除违章等级信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
/**
|
||||
* 获取违章等级视图对象
|
||||
*
|
||||
* @param violationLevel 违章等级对象
|
||||
* @return 违章等级视图对象
|
||||
*/
|
||||
HseViolationLevelByPostVo getVo(HseViolationLevel violationLevel);
|
||||
|
||||
/**
|
||||
* 获取违章等级查询条件封装
|
||||
*
|
||||
* @param req 违章等级查询条件
|
||||
* @return 违章等级查询条件封装
|
||||
*/
|
||||
LambdaQueryWrapper<HseViolationLevel> buildQueryWrapper(HseViolationLevelQueryReq req);
|
||||
|
||||
/**
|
||||
* 获取违章等级分页对象视图
|
||||
*
|
||||
* @param violationLevelPage 违章等级分页对象
|
||||
* @return 违章等级分页对象视图
|
||||
*/
|
||||
Page<HseViolationLevelVo> getVoPage(Page<HseViolationLevel> violationLevelPage);
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package org.dromara.safety.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.dromara.safety.domain.HseViolationLevelPost;
|
||||
import org.dromara.safety.mapper.HseViolationLevelPostMapper;
|
||||
import org.dromara.safety.service.IHseViolationLevelPostService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 等级与岗位关联Service业务层处理
|
||||
*
|
||||
* @author lcj
|
||||
* @date 2025-06-20
|
||||
*/
|
||||
@Service
|
||||
public class HseViolationLevelPostServiceImpl extends ServiceImpl<HseViolationLevelPostMapper, HseViolationLevelPost>
|
||||
implements IHseViolationLevelPostService {
|
||||
|
||||
}
|
@ -0,0 +1,316 @@
|
||||
package org.dromara.safety.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.dromara.common.core.constant.HttpStatus;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.ObjectUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.project.service.IBusProjectService;
|
||||
import org.dromara.safety.domain.HseViolationLevel;
|
||||
import org.dromara.safety.domain.HseViolationLevelPost;
|
||||
import org.dromara.safety.domain.dto.violationlevel.HseViolationLevelCreateReq;
|
||||
import org.dromara.safety.domain.dto.violationlevel.HseViolationLevelQueryReq;
|
||||
import org.dromara.safety.domain.dto.violationlevel.HseViolationLevelUpdateReq;
|
||||
import org.dromara.safety.domain.vo.violationlevel.HseViolationLevelByPostVo;
|
||||
import org.dromara.safety.domain.vo.violationlevel.HseViolationLevelVo;
|
||||
import org.dromara.safety.mapper.HseViolationLevelMapper;
|
||||
import org.dromara.safety.service.IHseViolationLevelPostService;
|
||||
import org.dromara.safety.service.IHseViolationLevelService;
|
||||
import org.dromara.system.domain.vo.SysPostVo;
|
||||
import org.dromara.system.service.ISysPostService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 违章等级Service业务层处理
|
||||
*
|
||||
* @author lcj
|
||||
* @date 2025-06-20
|
||||
*/
|
||||
@Service
|
||||
public class HseViolationLevelServiceImpl extends ServiceImpl<HseViolationLevelMapper, HseViolationLevel>
|
||||
implements IHseViolationLevelService {
|
||||
|
||||
@Resource
|
||||
private IBusProjectService projectService;
|
||||
|
||||
@Resource
|
||||
private IHseViolationLevelPostService violationLevelPostService;
|
||||
|
||||
@Resource
|
||||
private ISysPostService postService;
|
||||
|
||||
/**
|
||||
* 查询违章等级
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 违章等级
|
||||
*/
|
||||
@Override
|
||||
public HseViolationLevelByPostVo queryById(Long id) {
|
||||
HseViolationLevel violationLevel = this.getById(id);
|
||||
if (violationLevel == null) {
|
||||
throw new ServiceException("违章等级信息不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
return this.getVo(violationLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询违章等级列表
|
||||
*
|
||||
* @param req 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 违章等级分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<HseViolationLevelVo> queryPageList(HseViolationLevelQueryReq req, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<HseViolationLevel> lqw = buildQueryWrapper(req);
|
||||
Page<HseViolationLevel> result = this.page(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(this.getVoPage(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的违章等级列表
|
||||
*
|
||||
* @param req 查询条件
|
||||
* @return 违章等级列表
|
||||
*/
|
||||
@Override
|
||||
public List<HseViolationLevelVo> queryList(HseViolationLevelQueryReq req) {
|
||||
LambdaQueryWrapper<HseViolationLevel> lqw = buildQueryWrapper(req);
|
||||
return this.list(lqw).stream().map(violationLevel -> {
|
||||
HseViolationLevelVo vo = new HseViolationLevelVo();
|
||||
BeanUtils.copyProperties(violationLevel, vo);
|
||||
return vo;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增违章等级
|
||||
*
|
||||
* @param req 违章等级
|
||||
* @return 新增违章等级主键id
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long insertByBo(HseViolationLevelCreateReq req) {
|
||||
HseViolationLevel violationLevel = new HseViolationLevel();
|
||||
BeanUtils.copyProperties(req, violationLevel);
|
||||
// 校验参数
|
||||
validEntityBeforeSave(violationLevel, true);
|
||||
List<Long> postIdList = req.getPostIdList();
|
||||
if (CollUtil.isEmpty(postIdList)) {
|
||||
throw new ServiceException("岗位不能为空", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
// 判断违章等级是否存在
|
||||
Long count = this.lambdaQuery()
|
||||
.eq(HseViolationLevel::getViolationLevel, violationLevel)
|
||||
.count();
|
||||
if (count > 0) {
|
||||
throw new ServiceException("违章等级已存在", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
boolean result = this.save(violationLevel);
|
||||
if (!result) {
|
||||
throw new ServiceException("新增违章等级失败", HttpStatus.ERROR);
|
||||
}
|
||||
Long id = violationLevel.getId();
|
||||
// 新增岗位与违章等级关联
|
||||
List<HseViolationLevelPost> postList = postIdList.stream().map(postId -> {
|
||||
HseViolationLevelPost violationLevelPost = new HseViolationLevelPost();
|
||||
violationLevelPost.setLevel(id);
|
||||
violationLevelPost.setPost(postId);
|
||||
return violationLevelPost;
|
||||
}).toList();
|
||||
boolean saveRelevancy = violationLevelPostService.saveBatch(postList);
|
||||
if (!saveRelevancy) {
|
||||
throw new ServiceException("新增岗位与违章等级关联失败,数据库异常", HttpStatus.ERROR);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改违章等级
|
||||
*
|
||||
* @param req 违章等级
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean updateByBo(HseViolationLevelUpdateReq req) {
|
||||
HseViolationLevel violationLevel = new HseViolationLevel();
|
||||
BeanUtils.copyProperties(req, violationLevel);
|
||||
validEntityBeforeSave(violationLevel, false);
|
||||
Long id = req.getId();
|
||||
HseViolationLevel oldViolationLevel = this.getById(id);
|
||||
if (oldViolationLevel == null) {
|
||||
throw new ServiceException("修改的违章等级信息不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
List<Long> postIdList = req.getPostIdList();
|
||||
if (CollUtil.isNotEmpty(postIdList)) {
|
||||
List<Long> oldPostIdList = violationLevelPostService.lambdaQuery()
|
||||
.eq(HseViolationLevelPost::getLevel, id)
|
||||
.select(HseViolationLevelPost::getPost)
|
||||
.list().stream().map(HseViolationLevelPost::getPost).toList();
|
||||
// 转换为 Set
|
||||
Set<Long> newSet = new HashSet<>(postIdList);
|
||||
Set<Long> oldSet = new HashSet<>(oldPostIdList);
|
||||
// 需要添加的岗位ID(在 new 中有,但在 old 中没有)
|
||||
Set<Long> needAdd = new HashSet<>(newSet);
|
||||
needAdd.removeAll(oldSet);
|
||||
// 需要删除的岗位ID(在 old 中有,但在 new 中没有)
|
||||
Set<Long> needDelete = new HashSet<>(oldSet);
|
||||
needDelete.removeAll(newSet);
|
||||
// 执行新增
|
||||
if (CollUtil.isNotEmpty(needAdd)) {
|
||||
List<HseViolationLevelPost> addList = needAdd.stream().map(postId -> {
|
||||
HseViolationLevelPost item = new HseViolationLevelPost();
|
||||
item.setLevel(id);
|
||||
item.setPost(postId);
|
||||
return item;
|
||||
}).toList();
|
||||
boolean result = violationLevelPostService.saveBatch(addList);
|
||||
if (!result) {
|
||||
throw new ServiceException("新增岗位与违章等级关联失败,数据库异常", HttpStatus.ERROR);
|
||||
}
|
||||
}
|
||||
// 执行删除
|
||||
if (CollUtil.isNotEmpty(needDelete)) {
|
||||
boolean remove = violationLevelPostService.lambdaUpdate()
|
||||
.eq(HseViolationLevelPost::getLevel, id)
|
||||
.in(HseViolationLevelPost::getPost, needDelete)
|
||||
.remove();
|
||||
if (!remove) {
|
||||
throw new ServiceException("删除岗位与违章等级关联失败,数据库异常", HttpStatus.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean result = this.updateById(violationLevel);
|
||||
if (!result) {
|
||||
throw new ServiceException("修改违章等级失败", HttpStatus.ERROR);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(HseViolationLevel entity, Boolean create) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
Long projectId = entity.getProjectId();
|
||||
String violationLevel = entity.getViolationLevel();
|
||||
if (create) {
|
||||
if (projectId == null) {
|
||||
throw new ServiceException("项目id不能为空", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (StringUtils.isEmpty(violationLevel)) {
|
||||
throw new ServiceException("违章等级不能为空", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
if (projectId != null && projectService.getById(projectId) == null) {
|
||||
throw new ServiceException("对应项目不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除违章等级信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
List<HseViolationLevel> violationLevelList = this.listByIds(ids);
|
||||
if (isValid) {
|
||||
// TODO 做一些业务上的校验,判断是否需要校验
|
||||
List<Long> projectIds = violationLevelList.stream().map(HseViolationLevel::getProjectId).distinct().toList();
|
||||
projectService.validAuth(projectIds, userId);
|
||||
}
|
||||
return this.removeBatchByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取违章等级视图对象
|
||||
*
|
||||
* @param violationLevel 违章等级对象
|
||||
* @return 违章等级视图对象
|
||||
*/
|
||||
@Override
|
||||
public HseViolationLevelByPostVo getVo(HseViolationLevel violationLevel) {
|
||||
HseViolationLevelByPostVo vo = new HseViolationLevelByPostVo();
|
||||
if (violationLevel == null) {
|
||||
return vo;
|
||||
}
|
||||
BeanUtils.copyProperties(violationLevel, vo);
|
||||
List<HseViolationLevelPost> levelPostList = violationLevelPostService.lambdaQuery()
|
||||
.eq(HseViolationLevelPost::getLevel, violationLevel.getId())
|
||||
.list();
|
||||
if (CollUtil.isNotEmpty(levelPostList)) {
|
||||
List<Long> postIdList = levelPostList.stream().map(HseViolationLevelPost::getPost).toList();
|
||||
List<SysPostVo> postList = postService.selectPostByIds(postIdList);
|
||||
vo.setPostList(postList);
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取违章等级查询条件封装
|
||||
*
|
||||
* @param req 违章等级查询条件
|
||||
* @return 违章等级查询条件封装
|
||||
*/
|
||||
@Override
|
||||
public LambdaQueryWrapper<HseViolationLevel> buildQueryWrapper(HseViolationLevelQueryReq req) {
|
||||
LambdaQueryWrapper<HseViolationLevel> lqw = new LambdaQueryWrapper<>();
|
||||
Long projectId = req.getProjectId();
|
||||
String violationLevel = req.getViolationLevel();
|
||||
String riskType = req.getRiskType();
|
||||
String violationType = req.getViolationType();
|
||||
lqw.eq(ObjectUtils.isNotEmpty(projectId), HseViolationLevel::getProjectId, projectId);
|
||||
lqw.like(StringUtils.isNotBlank(violationLevel), HseViolationLevel::getViolationLevel, violationLevel);
|
||||
lqw.eq(StringUtils.isNotBlank(riskType), HseViolationLevel::getRiskType, riskType);
|
||||
// todo
|
||||
lqw.eq(StringUtils.isNotBlank(violationType), HseViolationLevel::getViolationType, violationType);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取违章等级分页对象视图
|
||||
*
|
||||
* @param violationLevelPage 违章等级分页对象
|
||||
* @return 违章等级分页对象视图
|
||||
*/
|
||||
@Override
|
||||
public Page<HseViolationLevelVo> getVoPage(Page<HseViolationLevel> violationLevelPage) {
|
||||
List<HseViolationLevel> violationLevelList = violationLevelPage.getRecords();
|
||||
Page<HseViolationLevelVo> violationLevelVoPage = new Page<>(
|
||||
violationLevelPage.getCurrent(),
|
||||
violationLevelPage.getSize(),
|
||||
violationLevelPage.getTotal());
|
||||
if (CollUtil.isEmpty(violationLevelList)) {
|
||||
return violationLevelVoPage;
|
||||
}
|
||||
List<HseViolationLevelVo> violationLevelVoList = violationLevelList.stream().map(violationLevel -> {
|
||||
HseViolationLevelVo vo = new HseViolationLevelVo();
|
||||
BeanUtils.copyProperties(violationLevel, vo);
|
||||
return vo;
|
||||
}).toList();
|
||||
violationLevelVoPage.setRecords(violationLevelVoList);
|
||||
return violationLevelVoPage;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.safety.mapper.HseViolationLevelMapper">
|
||||
|
||||
</mapper>
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.safety.mapper.HseViolationLevelPostMapper">
|
||||
|
||||
</mapper>
|
@ -557,3 +557,43 @@ values(1935231471757307910, '萤石摄像头图片删除', 1935231471757307906,
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1935231471757307911, '萤石摄像头图片导出', 1935231471757307906, '5', '#', '', 1, 0, 'F', '0', '0', 'other:ys7DeviceImg:export', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
-- 菜单 SQL
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1935896590929661954, '违章等级', '1935597155897143297', '1', 'violationLevel', 'safety/violationLevel/index', 1, 0, 'C', '0', '0', 'safety:violationLevel:list', '#', 103, 1, sysdate(), null, null, '违章等级菜单');
|
||||
|
||||
-- 按钮 SQL
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1935896590929661955, '违章等级查询', 1935896590929661954, '1', '#', '', 1, 0, 'F', '0', '0', 'safety:violationLevel:query', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1935896590929661956, '违章等级新增', 1935896590929661954, '2', '#', '', 1, 0, 'F', '0', '0', 'safety:violationLevel:add', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1935896590929661957, '违章等级修改', 1935896590929661954, '3', '#', '', 1, 0, 'F', '0', '0', 'safety:violationLevel:edit', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1935896590929661958, '违章等级删除', 1935896590929661954, '4', '#', '', 1, 0, 'F', '0', '0', 'safety:violationLevel:remove', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1935896590929661959, '违章等级导出', 1935896590929661954, '5', '#', '', 1, 0, 'F', '0', '0', 'safety:violationLevel:export', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
-- 菜单 SQL
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1935909171354439681, '等级与岗位关联', '1935896590929661954', '1', 'violationLevelPost', 'safety/violationLevelPost/index', 1, 0, 'C', '0', '0', 'safety:violationLevelPost:list', '#', 103, 1, sysdate(), null, null, '等级与岗位关联菜单');
|
||||
|
||||
-- 按钮 SQL
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1935909171354439682, '等级与岗位关联查询', 1935909171354439681, '1', '#', '', 1, 0, 'F', '0', '0', 'safety:violationLevelPost:query', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1935909171354439683, '等级与岗位关联新增', 1935909171354439681, '2', '#', '', 1, 0, 'F', '0', '0', 'safety:violationLevelPost:add', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1935909171354439684, '等级与岗位关联修改', 1935909171354439681, '3', '#', '', 1, 0, 'F', '0', '0', 'safety:violationLevelPost:edit', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1935909171354439685, '等级与岗位关联删除', 1935909171354439681, '4', '#', '', 1, 0, 'F', '0', '0', 'safety:violationLevelPost:remove', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(1935909171354439686, '等级与岗位关联导出', 1935909171354439681, '5', '#', '', 1, 0, 'F', '0', '0', 'safety:violationLevelPost:export', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
@ -1136,3 +1136,11 @@ CREATE TABLE `hse_violation_level`
|
||||
primary key (`id`) using btree,
|
||||
index `idx_project_id` (`project_id` asc) using btree comment '项目id'
|
||||
) comment = '违章等级' collate = utf8mb4_unicode_ci;
|
||||
|
||||
DROP TABLE IF EXISTS `hse_violation_level_post`;
|
||||
CREATE TABLE `hse_violation_level_post`
|
||||
(
|
||||
`level` bigint not null comment '等级',
|
||||
`post` bigint not null comment '岗位',
|
||||
primary key (`level`, `post`) using btree
|
||||
) comment = '等级与岗位关联' collate = utf8mb4_unicode_ci;
|
||||
|
Reference in New Issue
Block a user