添加功能
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
package com.ruoyi.cms.controller;
|
||||
|
||||
import com.ruoyi.cms.domain.ModelWarningIndicator;
|
||||
import com.ruoyi.cms.domain.vo.TreeVo;
|
||||
import com.ruoyi.cms.service.ModelWarningIndicatorService;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 就业失业预警指标
|
||||
*
|
||||
* @author 马宝龙
|
||||
* @date 2026/7/1
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/model/warningIndicator")
|
||||
@RequiredArgsConstructor
|
||||
public class ModelWarningIndicatorController extends BaseController {
|
||||
|
||||
private final ModelWarningIndicatorService modelWarningIndicatorService;
|
||||
|
||||
/**
|
||||
* 创建指标
|
||||
*
|
||||
* @param modelWarningIndicator 指标
|
||||
* @return 创建结果
|
||||
*/
|
||||
@PostMapping("/create")
|
||||
public AjaxResult createIndicator(@Valid @RequestBody ModelWarningIndicator modelWarningIndicator) {
|
||||
modelWarningIndicatorService.create(modelWarningIndicator);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新指标
|
||||
*
|
||||
* @param modelWarningIndicator 指标
|
||||
* @return 更新结果
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public AjaxResult updateIndicator(@Valid @RequestBody ModelWarningIndicator modelWarningIndicator) {
|
||||
modelWarningIndicatorService.update(modelWarningIndicator);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指标
|
||||
*
|
||||
* @param id 指标id
|
||||
* @return 删除结果
|
||||
*/
|
||||
@DeleteMapping("/delete")
|
||||
public AjaxResult deleteIndicator(@RequestParam Long id) {
|
||||
modelWarningIndicatorService.delete(id);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指标详情
|
||||
*
|
||||
* @param id ID
|
||||
* @return 指标
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public AjaxResult detail(@RequestParam Long id) {
|
||||
ModelWarningIndicator indicator = modelWarningIndicatorService.detail(id);
|
||||
return AjaxResult.success(indicator);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分页列表
|
||||
*
|
||||
* @param modelWarningIndicator 指标
|
||||
* @return 分页列表
|
||||
*/
|
||||
@PostMapping("/page")
|
||||
@ResponseBody
|
||||
public TableDataInfo page(@RequestBody ModelWarningIndicator modelWarningIndicator) {
|
||||
startPage();
|
||||
List<ModelWarningIndicator> list = modelWarningIndicatorService.list(modelWarningIndicator);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 树结构
|
||||
*
|
||||
* @return 树结构
|
||||
*/
|
||||
@GetMapping("/tree")
|
||||
public AjaxResult tree() {
|
||||
|
||||
List<TreeVo> treeList = new ArrayList<>();
|
||||
treeList.add(TreeVo.builder()
|
||||
.id(1L)
|
||||
.code("1")
|
||||
.desc("就业指标")
|
||||
.children(modelWarningIndicatorService.tree(1))
|
||||
.build());
|
||||
treeList.add(TreeVo.builder()
|
||||
.id(2L)
|
||||
.code("2")
|
||||
.desc("失业指标")
|
||||
.children(modelWarningIndicatorService.tree(2))
|
||||
.build());
|
||||
treeList.add(TreeVo.builder()
|
||||
.id(3L)
|
||||
.code("3")
|
||||
.desc("经济指标")
|
||||
.children(modelWarningIndicatorService.tree(3))
|
||||
.build());
|
||||
|
||||
return AjaxResult.success(treeList);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.ruoyi.cms.domain;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 就业失业预警指标
|
||||
*
|
||||
* @author 马宝龙
|
||||
* @date 2026/7/1
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ModelWarningIndicator implements Serializable {
|
||||
private static final long serialVersionUID = -3444223057995852026L;
|
||||
|
||||
private Long id;
|
||||
/**
|
||||
* 指标名称
|
||||
*/
|
||||
@Excel(name = "指标名称")
|
||||
private String indicatorName;
|
||||
/**
|
||||
* 指标编码
|
||||
*/
|
||||
@Excel(name = "指标编码")
|
||||
private String indicatorCode;
|
||||
/**
|
||||
* 指标类型(1-就业指标 2-失业指标 3-经济指标)
|
||||
*/
|
||||
@Excel(name = "指标类型")
|
||||
private Integer indicatorType;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Excel(name = "排序")
|
||||
private Integer sortOrder;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.ruoyi.cms.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 树状结构
|
||||
*
|
||||
* @author 马宝龙
|
||||
* @date 2026/7/1
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TreeVo implements Serializable {
|
||||
private static final long serialVersionUID = 830000385760580785L;
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String desc;
|
||||
/**
|
||||
* 子节点
|
||||
*/
|
||||
private List<TreeVo> children;
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.ruoyi.cms.mapper;
|
||||
|
||||
import com.ruoyi.cms.domain.ModelWarningIndicator;
|
||||
import com.ruoyi.cms.domain.vo.TreeVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 就业失业预警指标
|
||||
*
|
||||
* @author 马宝龙
|
||||
* @date 2026/7/1
|
||||
*/
|
||||
public interface ModelWarningIndicatorMapper {
|
||||
|
||||
/**
|
||||
* 新增指标
|
||||
*
|
||||
* @param modelWarningIndicator 指标
|
||||
*/
|
||||
void insert(ModelWarningIndicator modelWarningIndicator);
|
||||
|
||||
/**
|
||||
* 修改指标
|
||||
*
|
||||
* @param modelWarningIndicator 指标
|
||||
*/
|
||||
void update(ModelWarningIndicator modelWarningIndicator);
|
||||
|
||||
/**
|
||||
* 通过ID删除指标
|
||||
*
|
||||
* @param id ID
|
||||
*/
|
||||
void deleteById(Long id);
|
||||
|
||||
/**
|
||||
* 通过ID查询指标
|
||||
*
|
||||
* @param id ID
|
||||
* @return 指标
|
||||
*/
|
||||
ModelWarningIndicator selectById(Long id);
|
||||
|
||||
/**
|
||||
* 查询唯一
|
||||
*
|
||||
* @param modelWarningIndicator 指标
|
||||
* @return 指标
|
||||
*/
|
||||
ModelWarningIndicator findUnique(ModelWarningIndicator modelWarningIndicator);
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*
|
||||
* @param modelWarningIndicator 指标
|
||||
* @return 列表
|
||||
*/
|
||||
List<ModelWarningIndicator> list(ModelWarningIndicator modelWarningIndicator);
|
||||
|
||||
/**
|
||||
* 树结构
|
||||
*
|
||||
* @param indicatorType 指标类型
|
||||
* @return 树结构
|
||||
*/
|
||||
List<TreeVo> tree(Integer indicatorType);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.ruoyi.cms.service;
|
||||
|
||||
import com.ruoyi.cms.domain.ModelWarningIndicator;
|
||||
import com.ruoyi.cms.domain.vo.TreeVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 就业失业预警指标
|
||||
*
|
||||
* @author 马宝龙
|
||||
* @date 2026/7/1
|
||||
*/
|
||||
public interface ModelWarningIndicatorService {
|
||||
|
||||
/**
|
||||
* 创建指标
|
||||
*
|
||||
* @param modelWarningIndicator 指标
|
||||
*/
|
||||
void create(ModelWarningIndicator modelWarningIndicator);
|
||||
|
||||
/**
|
||||
* 更新指标
|
||||
*
|
||||
* @param modelWarningIndicator 指标
|
||||
*/
|
||||
void update(ModelWarningIndicator modelWarningIndicator);
|
||||
|
||||
/**
|
||||
* 删除指标
|
||||
*
|
||||
* @param id 指标id
|
||||
*/
|
||||
void delete(Long id);
|
||||
|
||||
/**
|
||||
* 查询指标详情
|
||||
*
|
||||
* @param id ID
|
||||
* @return 指标
|
||||
*/
|
||||
ModelWarningIndicator detail(Long id);
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*
|
||||
* @param modelWarningIndicator 指标
|
||||
* @return 列表
|
||||
*/
|
||||
List<ModelWarningIndicator> list(ModelWarningIndicator modelWarningIndicator);
|
||||
|
||||
/**
|
||||
* 树结构
|
||||
*
|
||||
* @param indicatorType 指标类型
|
||||
* @return 树结构
|
||||
*/
|
||||
List<TreeVo> tree(Integer indicatorType);
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.ruoyi.cms.service.impl;
|
||||
|
||||
import com.ruoyi.cms.domain.ModelWarningIndicator;
|
||||
import com.ruoyi.cms.domain.vo.TreeVo;
|
||||
import com.ruoyi.cms.mapper.ModelWarningIndicatorMapper;
|
||||
import com.ruoyi.cms.service.ModelWarningIndicatorService;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 就业失业预警指标
|
||||
*
|
||||
* @author 马宝龙
|
||||
* @date 2026/7/1
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
public class ModelWarningIndicatorServiceImpl implements ModelWarningIndicatorService {
|
||||
|
||||
private final ModelWarningIndicatorMapper modelWarningIndicatorMapper;
|
||||
|
||||
@Override
|
||||
public void create(ModelWarningIndicator modelWarningIndicator) {
|
||||
|
||||
check(modelWarningIndicator);
|
||||
|
||||
// 查询唯一
|
||||
Optional<ModelWarningIndicator> optional = findUnique(modelWarningIndicator);
|
||||
if (optional.isPresent()) {
|
||||
// 更新
|
||||
ModelWarningIndicator exists = optional.get();
|
||||
modelWarningIndicator.setId(exists.getId());
|
||||
modelWarningIndicatorMapper.update(modelWarningIndicator);
|
||||
} else {
|
||||
// 新增
|
||||
modelWarningIndicatorMapper.insert(modelWarningIndicator);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查
|
||||
*
|
||||
* @param modelWarningIndicator 指标
|
||||
*/
|
||||
void check(ModelWarningIndicator modelWarningIndicator) {
|
||||
if (StringUtils.isBlank(modelWarningIndicator.getIndicatorName())) {
|
||||
throw new ServiceException("指标名称不能为空");
|
||||
}
|
||||
if (StringUtils.isBlank(modelWarningIndicator.getIndicatorCode())) {
|
||||
throw new ServiceException("指标编码不能为空");
|
||||
}
|
||||
Set<Integer> typeList = new HashSet<>();
|
||||
typeList.add(1);
|
||||
typeList.add(2);
|
||||
typeList.add(3);
|
||||
if (!typeList.contains(modelWarningIndicator.getIndicatorType())) {
|
||||
throw new ServiceException("指标类型错误");
|
||||
}
|
||||
if (Objects.isNull(modelWarningIndicator.getSortOrder())) {
|
||||
throw new ServiceException("排序不能为空");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(ModelWarningIndicator modelWarningIndicator) {
|
||||
|
||||
check(modelWarningIndicator);
|
||||
|
||||
if (Objects.isNull(modelWarningIndicator.getId())) {
|
||||
throw new ServiceException("id不能为空");
|
||||
}
|
||||
Optional<ModelWarningIndicator> unique = findUnique(modelWarningIndicator);
|
||||
if (!unique.isPresent()) {
|
||||
modelWarningIndicatorMapper.update(modelWarningIndicator);
|
||||
return;
|
||||
}
|
||||
ModelWarningIndicator exists = unique.get();
|
||||
if (!exists.getId().equals(modelWarningIndicator.getId())) {
|
||||
throw new ServiceException("指标已存在");
|
||||
}
|
||||
modelWarningIndicatorMapper.update(modelWarningIndicator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id) {
|
||||
if (Objects.isNull(id)) {
|
||||
throw new ServiceException("id不能为空");
|
||||
}
|
||||
// todo 判断 指标是否存在数据
|
||||
|
||||
modelWarningIndicatorMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelWarningIndicator detail(Long id) {
|
||||
|
||||
if (Objects.isNull(id)) {
|
||||
throw new ServiceException("id不能为空");
|
||||
}
|
||||
|
||||
return modelWarningIndicatorMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询唯一
|
||||
*
|
||||
* @param modelWarningIndicator 指标
|
||||
* @return 指标
|
||||
*/
|
||||
private Optional<ModelWarningIndicator> findUnique(ModelWarningIndicator modelWarningIndicator) {
|
||||
ModelWarningIndicator unique = modelWarningIndicatorMapper.findUnique(modelWarningIndicator);
|
||||
return Optional.ofNullable(unique);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ModelWarningIndicator> list(ModelWarningIndicator modelWarningIndicator) {
|
||||
return modelWarningIndicatorMapper.list(modelWarningIndicator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeVo> tree(Integer indicatorType) {
|
||||
if (Objects.isNull(indicatorType)) {
|
||||
throw new ServiceException("指标类型不能为空");
|
||||
}
|
||||
return modelWarningIndicatorMapper.tree(indicatorType);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?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="com.ruoyi.cms.mapper.ModelWarningIndicatorMapper">
|
||||
|
||||
<insert id="insert" parameterType="com.ruoyi.cms.domain.ModelWarningIndicator">
|
||||
INSERT INTO model_warning_indicator (indicator_name, indicator_code, indicator_type, sort_order)
|
||||
VALUES (#{indicatorName}, #{indicatorCode}, #{indicatorType}, #{sortOrder})
|
||||
</insert>
|
||||
|
||||
|
||||
<insert id="update" parameterType="com.ruoyi.cms.domain.ModelWarningIndicator">
|
||||
UPDATE
|
||||
model_warning_indicator
|
||||
SET indicator_name = #{indicatorName},
|
||||
indicator_code = #{indicatorCode},
|
||||
indicator_type = #{indicatorType},
|
||||
sort_order = #{sortOrder}
|
||||
WHERE id = #{id}
|
||||
</insert>
|
||||
|
||||
<insert id="deleteById" parameterType="java.lang.Long">
|
||||
DELETE
|
||||
FROM model_warning_indicator
|
||||
WHERE id = #{id}
|
||||
</insert>
|
||||
|
||||
<select id="selectById" parameterType="com.ruoyi.cms.domain.ModelWarningIndicator"
|
||||
resultType="com.ruoyi.cms.domain.ModelWarningIndicator">
|
||||
SELECT *
|
||||
FROM model_warning_indicator
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="findUnique" parameterType="com.ruoyi.cms.domain.ModelWarningIndicator"
|
||||
resultType="com.ruoyi.cms.domain.ModelWarningIndicator">
|
||||
SELECT *
|
||||
FROM model_warning_indicator
|
||||
WHERE indicator_code = #{indicatorCode}
|
||||
AND indicator_type = #{indicatorType}
|
||||
</select>
|
||||
|
||||
<select id="list" parameterType="com.ruoyi.cms.domain.ModelWarningIndicator"
|
||||
resultType="com.ruoyi.cms.domain.ModelWarningIndicator">
|
||||
SELECT *
|
||||
FROM model_warning_indicator
|
||||
<where>
|
||||
<if test="id != null ">
|
||||
AND id = #{id}
|
||||
</if>
|
||||
<if test="indicatorName != null and indicatorName != ''">
|
||||
AND indicator_name LIKE '%'||#{indicatorName} || '%'
|
||||
</if>
|
||||
<if test="indicatorCode != null and indicatorCode != ''">
|
||||
AND indicator_code = #{indicatorCode}
|
||||
</if>
|
||||
<if test="indicatorType != null and indicatorType != ''">
|
||||
AND indicator_type = #{indicatorType}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY sort_order
|
||||
</select>
|
||||
|
||||
<select id="tree" parameterType="java.lang.Integer"
|
||||
resultType="com.ruoyi.cms.domain.vo.TreeVo">
|
||||
SELECT id,
|
||||
indicator_name as "desc",
|
||||
indicator_code as code
|
||||
FROM model_warning_indicator
|
||||
WHERE indicator_type = #{indicatorType}
|
||||
ORDER BY sort_order
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -111,6 +111,8 @@ public class SecurityConfig {
|
||||
requests.antMatchers("/sso/pc/code/login").permitAll()
|
||||
// 大数据分析先放行
|
||||
.antMatchers("/analysis/**").permitAll()
|
||||
// 模型先放行
|
||||
.antMatchers("/model/**").permitAll()
|
||||
// 静态资源,可匿名访问
|
||||
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js",
|
||||
"/profile/**").permitAll()
|
||||
|
||||
@@ -695,3 +695,35 @@ ON COLUMN shz_data_dashboard.theme_job_seeker.user_type IS '用户类型';
|
||||
|
||||
COMMENT
|
||||
ON TABLE shz_data_dashboard.theme_job_seeker IS '求职者主题库';
|
||||
|
||||
-- 就业失业预警指标
|
||||
CREATE TABLE shz_data_dashboard.model_warning_indicator
|
||||
(
|
||||
id serial PRIMARY KEY,
|
||||
indicator_name character varying(400) NOT NULL COLLATE pg_catalog."default",
|
||||
indicator_code character varying(200) NOT NULL COLLATE pg_catalog."default",
|
||||
indicator_type smallint NOT NULL,
|
||||
sort_order integer NOT NULL
|
||||
)
|
||||
;
|
||||
|
||||
ALTER TABLE shz_data_dashboard.model_warning_indicator
|
||||
OWNER TO sysdba;
|
||||
|
||||
COMMENT
|
||||
ON COLUMN shz_data_dashboard.model_warning_indicator.id IS '主键';
|
||||
|
||||
COMMENT
|
||||
ON COLUMN shz_data_dashboard.model_warning_indicator.indicator_name IS '指标名称';
|
||||
|
||||
COMMENT
|
||||
ON COLUMN shz_data_dashboard.model_warning_indicator.indicator_code IS '指标编码';
|
||||
|
||||
COMMENT
|
||||
ON COLUMN shz_data_dashboard.model_warning_indicator.indicator_type IS '指标类型(1-就业指标 2-失业指标 3-经济指标)';
|
||||
|
||||
COMMENT
|
||||
ON COLUMN shz_data_dashboard.model_warning_indicator.sort_order IS '排序';
|
||||
|
||||
COMMENT
|
||||
ON TABLE shz_data_dashboard.model_warning_indicator IS '就业失业预警指标';
|
||||
Reference in New Issue
Block a user