添加功能

This commit is contained in:
马宝龙
2026-07-03 16:30:53 +08:00
parent 1e4928d3e6
commit d94364f1b0
10 changed files with 664 additions and 1 deletions

View File

@@ -30,6 +30,8 @@ public enum ModelTemplateTypeEnum {
MODEL_SUPPLY_MONITOR_INDUSTRY_POPULATION_RESULT("劳动力动态监测系统-劳动力供给结果分行业劳动力人口"),
MODEL_SUPPLY_MONITOR_OCCUPATION_POPULATION_RESULT("劳动力动态监测系统-劳动力供给结果分职业劳动力人口"),
MODEL_DEMAND_MONITOR_EMPLOYMENT("劳动力动态监测系统-劳动力需求就业人数"),
;
private final String desc;
}

View File

@@ -0,0 +1,104 @@
package com.ruoyi.cms.controller;
import com.ruoyi.cms.domain.ModelDemandMonitorEmployment;
import com.ruoyi.cms.service.ModelDemandMonitorEmploymentService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
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.RestController;
import javax.validation.Valid;
import java.util.List;
/**
* 劳动力需求就业人数
*
* @author 马宝龙
* @date 2026/7/3
*/
@RestController
@RequestMapping("/model/demandMonitorEmployment")
@RequiredArgsConstructor
public class ModelDemandMonitorEmploymentController extends BaseController {
private final ModelDemandMonitorEmploymentService modelDemandMonitorEmploymentService;
/**
* 创建
*
* @param modelDemandMonitorEmployment 劳动力需求就业人数
* @return 创建结果
*/
@PostMapping("/create")
public AjaxResult create(@Valid @RequestBody ModelDemandMonitorEmployment modelDemandMonitorEmployment) {
modelDemandMonitorEmploymentService.create(modelDemandMonitorEmployment);
return AjaxResult.success();
}
/**
* 更新
*
* @param modelDemandMonitorEmployment 劳动力需求就业人数
* @return 更新结果
*/
@PutMapping("/update")
public AjaxResult update(@Valid @RequestBody ModelDemandMonitorEmployment modelDemandMonitorEmployment) {
modelDemandMonitorEmploymentService.update(modelDemandMonitorEmployment);
return AjaxResult.success();
}
/**
* 删除
*
* @param id ID
* @return 删除结果
*/
@DeleteMapping("/delete")
public AjaxResult delete(@RequestParam Long id) {
modelDemandMonitorEmploymentService.delete(id);
return AjaxResult.success();
}
/**
* 清空
*
* @return 清空结果
*/
@DeleteMapping("/clear")
public AjaxResult clear() {
modelDemandMonitorEmploymentService.clear();
return AjaxResult.success();
}
/**
* 查询详情
*
* @param id ID
* @return 劳动力需求就业人数
*/
@GetMapping("/detail")
public AjaxResult detail(@RequestParam Long id) {
ModelDemandMonitorEmployment data = modelDemandMonitorEmploymentService.detail(id);
return AjaxResult.success(data);
}
/**
* 查询列表
*
* @param modelDemandMonitorEmployment 劳动力需求就业人数
* @return 列表
*/
@PostMapping("/list")
public AjaxResult list(@RequestBody ModelDemandMonitorEmployment modelDemandMonitorEmployment) {
List<ModelDemandMonitorEmployment> list =
modelDemandMonitorEmploymentService.list(modelDemandMonitorEmployment);
return AjaxResult.success(list);
}
}

View File

@@ -0,0 +1,53 @@
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/3
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ModelDemandMonitorEmployment implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private Long id;
/**
* 年份
*/
@Excel(name = "年份")
private Integer year;
/**
* 总就业人数(万人)
*/
@Excel(name = "总就业人数(万人)")
private Integer totalCount;
/**
* 第一产业就业人数(万人)
*/
@Excel(name = "第一产业就业人数(万人)")
private Integer firstIndustryCount;
/**
* 第二产业就业人数(万人)
*/
@Excel(name = "第二产业就业人数(万人)")
private Integer secondIndustryCount;
/**
* 第三产业就业人数(万人)
*/
@Excel(name = "第三产业就业人数(万人)")
private Integer thirdIndustryCount;
}

View File

@@ -0,0 +1,64 @@
package com.ruoyi.cms.mapper;
import com.ruoyi.cms.domain.ModelDemandMonitorEmployment;
import java.util.List;
/**
* 劳动力需求就业人数
*
* @author 马宝龙
* @date 2026/7/3
*/
public interface ModelDemandMonitorEmploymentMapper {
/**
* 新增
*
* @param modelDemandMonitorEmployment 劳动力需求就业人数
*/
void insert(ModelDemandMonitorEmployment modelDemandMonitorEmployment);
/**
* 修改
*
* @param modelDemandMonitorEmployment 劳动力需求就业人数
*/
void update(ModelDemandMonitorEmployment modelDemandMonitorEmployment);
/**
* 通过ID删除
*
* @param id ID
*/
void deleteById(Long id);
/**
* 清空
*/
void clear();
/**
* 通过ID查询
*
* @param id ID
* @return 劳动力需求就业人数
*/
ModelDemandMonitorEmployment selectById(Long id);
/**
* 查询唯一(按年份)
*
* @param modelDemandMonitorEmployment 劳动力需求就业人数
* @return 劳动力需求就业人数
*/
ModelDemandMonitorEmployment findUnique(ModelDemandMonitorEmployment modelDemandMonitorEmployment);
/**
* 查询列表
*
* @param modelDemandMonitorEmployment 劳动力需求就业人数
* @return 列表
*/
List<ModelDemandMonitorEmployment> list(ModelDemandMonitorEmployment modelDemandMonitorEmployment);
}

View File

@@ -0,0 +1,75 @@
package com.ruoyi.cms.service;
import com.ruoyi.cms.domain.ModelDemandMonitorEmployment;
import com.ruoyi.cms.domain.dto.ModelExportParamDto;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 劳动力需求就业人数
*
* @author 马宝龙
* @date 2026/7/3
*/
public interface ModelDemandMonitorEmploymentService {
/**
* 创建
*
* @param modelDemandMonitorEmployment 劳动力需求就业人数
*/
void create(ModelDemandMonitorEmployment modelDemandMonitorEmployment);
/**
* 更新
*
* @param modelDemandMonitorEmployment 劳动力需求就业人数
*/
void update(ModelDemandMonitorEmployment modelDemandMonitorEmployment);
/**
* 删除
*
* @param id ID
*/
void delete(Long id);
/**
* 清空
*/
void clear();
/**
* 查询详情
*
* @param id ID
* @return 劳动力需求就业人数
*/
ModelDemandMonitorEmployment detail(Long id);
/**
* 查询列表
*
* @param modelDemandMonitorEmployment 劳动力需求就业人数
* @return 列表
*/
List<ModelDemandMonitorEmployment> list(ModelDemandMonitorEmployment modelDemandMonitorEmployment);
/**
* 导入数据
*
* @param file 文件
* @return 导入结果
*/
String importExcel(MultipartFile file);
/**
* 导出数据
*
* @param response 响应体
* @param dto 导出参数
*/
void exportExcel(HttpServletResponse response, ModelExportParamDto dto);
}

View File

@@ -3,6 +3,7 @@ package com.ruoyi.cms.service.impl;
import com.ruoyi.cms.constant.enums.ModelTemplateTypeEnum;
import com.ruoyi.cms.domain.dto.ModelExportParamDto;
import com.ruoyi.cms.service.ModelCommonService;
import com.ruoyi.cms.service.ModelDemandMonitorEmploymentService;
import com.ruoyi.cms.service.ModelSupplyMonitorIndustryPopulationService;
import com.ruoyi.cms.service.ModelSupplyMonitorLaborJoinRateService;
import com.ruoyi.cms.service.ModelSupplyMonitorOccupationPopulationService;
@@ -44,6 +45,7 @@ public class ModelCommonServiceImpl implements ModelCommonService {
private final ModelSupplyMonitorLaborJoinRateService modelSupplyMonitorLaborJoinRateService;
private final ModelSupplyMonitorIndustryPopulationService modelSupplyMonitorIndustryPopulationService;
private final ModelSupplyMonitorOccupationPopulationService modelSupplyMonitorOccupationPopulationService;
private final ModelDemandMonitorEmploymentService modelDemandMonitorEmploymentService;
@Override
public void template(HttpServletResponse response,
@@ -99,6 +101,8 @@ public class ModelCommonServiceImpl implements ModelCommonService {
return modelSupplyMonitorIndustryPopulationService.importExcel(file);
case MODEL_SUPPLY_MONITOR_OCCUPATION_POPULATION:
return modelSupplyMonitorOccupationPopulationService.importExcel(file);
case MODEL_DEMAND_MONITOR_EMPLOYMENT:
return modelDemandMonitorEmploymentService.importExcel(file);
default:
throw new ServiceException("模板类型错误");
}
@@ -132,6 +136,9 @@ public class ModelCommonServiceImpl implements ModelCommonService {
case MODEL_SUPPLY_MONITOR_OCCUPATION_POPULATION_RESULT:
modelSupplyMonitorOccupationPopulationService.exportExcel(response, dto);
break;
case MODEL_DEMAND_MONITOR_EMPLOYMENT:
modelDemandMonitorEmploymentService.exportExcel(response, dto);
break;
default:
throw new ServiceException("模板类型错误");
}

View File

@@ -0,0 +1,209 @@
package com.ruoyi.cms.service.impl;
import com.ruoyi.cms.constant.enums.ModelTemplateTypeEnum;
import com.ruoyi.cms.domain.ModelDemandMonitorEmployment;
import com.ruoyi.cms.domain.dto.ModelExportParamDto;
import com.ruoyi.cms.mapper.ModelDemandMonitorEmploymentMapper;
import com.ruoyi.cms.service.ModelDemandMonitorEmploymentService;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.bean.BeanValidators;
import com.ruoyi.common.utils.poi.ExcelUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Validator;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
/**
* 劳动力需求就业人数
*
* @author 马宝龙
* @date 2026/7/3
*/
@Slf4j
@Service
@Validated
@RequiredArgsConstructor
public class ModelDemandMonitorEmploymentServiceImpl implements ModelDemandMonitorEmploymentService {
private final ModelDemandMonitorEmploymentMapper modelDemandMonitorEmploymentMapper;
private final Validator validator;
@Override
public void create(ModelDemandMonitorEmployment modelDemandMonitorEmployment) {
check(modelDemandMonitorEmployment);
// 查询唯一(按年份)
Optional<ModelDemandMonitorEmployment> optional = findUnique(modelDemandMonitorEmployment);
if (optional.isPresent()) {
// 更新
ModelDemandMonitorEmployment exists = optional.get();
modelDemandMonitorEmployment.setId(exists.getId());
modelDemandMonitorEmploymentMapper.update(modelDemandMonitorEmployment);
} else {
// 新增
modelDemandMonitorEmploymentMapper.insert(modelDemandMonitorEmployment);
}
}
/**
* 检查
*
* @param modelDemandMonitorEmployment 劳动力需求就业人数
*/
void check(ModelDemandMonitorEmployment modelDemandMonitorEmployment) {
if (Objects.isNull(modelDemandMonitorEmployment.getYear())) {
throw new ServiceException("年份不能为空");
}
if (Objects.isNull(modelDemandMonitorEmployment.getTotalCount())) {
throw new ServiceException("总就业人数不能为空");
}
if (Objects.isNull(modelDemandMonitorEmployment.getFirstIndustryCount())) {
throw new ServiceException("第一产业就业人数不能为空");
}
if (Objects.isNull(modelDemandMonitorEmployment.getSecondIndustryCount())) {
throw new ServiceException("第二产业就业人数不能为空");
}
if (Objects.isNull(modelDemandMonitorEmployment.getThirdIndustryCount())) {
throw new ServiceException("第三产业就业人数不能为空");
}
if (modelDemandMonitorEmployment.getTotalCount() !=
(modelDemandMonitorEmployment.getFirstIndustryCount() +
modelDemandMonitorEmployment.getSecondIndustryCount() +
modelDemandMonitorEmployment.getThirdIndustryCount())) {
throw new ServiceException("总就业人数和第一产业就业人数、第二产业就业人数、第三产业就业人数不相等");
}
}
@Override
public void update(ModelDemandMonitorEmployment modelDemandMonitorEmployment) {
check(modelDemandMonitorEmployment);
if (Objects.isNull(modelDemandMonitorEmployment.getId())) {
throw new ServiceException("id不能为空");
}
Optional<ModelDemandMonitorEmployment> unique = findUnique(modelDemandMonitorEmployment);
if (!unique.isPresent()) {
modelDemandMonitorEmploymentMapper.update(modelDemandMonitorEmployment);
return;
}
ModelDemandMonitorEmployment exists = unique.get();
if (!exists.getId().equals(modelDemandMonitorEmployment.getId())) {
throw new ServiceException("数据已存在");
}
modelDemandMonitorEmploymentMapper.update(modelDemandMonitorEmployment);
}
@Override
public void delete(Long id) {
if (Objects.isNull(id)) {
throw new ServiceException("id不能为空");
}
modelDemandMonitorEmploymentMapper.deleteById(id);
}
@Override
public void clear() {
modelDemandMonitorEmploymentMapper.clear();
}
@Override
public ModelDemandMonitorEmployment detail(Long id) {
if (Objects.isNull(id)) {
throw new ServiceException("id不能为空");
}
return modelDemandMonitorEmploymentMapper.selectById(id);
}
/**
* 查询唯一
*
* @param modelDemandMonitorEmployment 劳动力需求就业人数
* @return 劳动力需求就业人数
*/
private Optional<ModelDemandMonitorEmployment> findUnique(ModelDemandMonitorEmployment modelDemandMonitorEmployment) {
ModelDemandMonitorEmployment unique =
modelDemandMonitorEmploymentMapper.findUnique(modelDemandMonitorEmployment);
return Optional.ofNullable(unique);
}
@Override
public List<ModelDemandMonitorEmployment> list(ModelDemandMonitorEmployment modelDemandMonitorEmployment) {
return modelDemandMonitorEmploymentMapper.list(modelDemandMonitorEmployment);
}
@Override
public String importExcel(MultipartFile file) {
try {
ExcelUtil<ModelDemandMonitorEmployment> util = new ExcelUtil<>(ModelDemandMonitorEmployment.class);
List<ModelDemandMonitorEmployment> list = util.importExcel(file.getInputStream());
ModelDemandMonitorEmployment exists;
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
for (ModelDemandMonitorEmployment item : list) {
try {
check(item);
exists = modelDemandMonitorEmploymentMapper.findUnique(item);
if (exists == null) {
BeanValidators.validateWithException(validator, item);
modelDemandMonitorEmploymentMapper.insert(item);
successNum++;
String msg =
"<br/>" + successNum + "" + "年份:" + item.getYear() + "数据导入成功。";
successMsg.append(msg);
} else {
item.setId(exists.getId());
BeanValidators.validateWithException(validator, item);
modelDemandMonitorEmploymentMapper.update(item);
successNum++;
String msg =
"<br/>" + successNum + "" + "年份:" + item.getYear() + "数据更新成功。";
successMsg.append(msg);
}
} catch (Exception e) {
failureNum++;
String msg = "<br/>" + failureNum + "" + "年份:" + item.getYear() + "数据导入失败:";
failureMsg.append(msg).append(e.getMessage());
log.error(msg, e);
}
}
if (failureNum > 0) {
failureMsg.insert(0, "导入失败!共 " + failureNum + " 条数据出现问题,错误如下:");
throw new ServiceException(failureMsg.toString());
} else {
successMsg.insert(0, "数据已全部导入成功!共 " + successNum + " 条:");
}
return successMsg.toString();
} catch (Exception e) {
log.error("数据导入失败", e);
throw new ServiceException("数据导入失败");
}
}
@Override
public void exportExcel(HttpServletResponse response, ModelExportParamDto dto) {
try {
List<ModelDemandMonitorEmployment> list = list(ModelDemandMonitorEmployment.builder()
.year(dto.getYear())
.build());
ExcelUtil<ModelDemandMonitorEmployment> util = new ExcelUtil<>(ModelDemandMonitorEmployment.class);
util.exportExcel(response, list, ModelTemplateTypeEnum.MODEL_DEMAND_MONITOR_EMPLOYMENT.getDesc());
} catch (Exception e) {
log.error("数据导出失败", e);
throw new ServiceException("数据导出失败");
}
}
}

View File

@@ -0,0 +1,75 @@
<?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.ModelDemandMonitorEmploymentMapper">
<insert id="insert" parameterType="com.ruoyi.cms.domain.ModelDemandMonitorEmployment">
INSERT INTO model_demand_monitor_employment (year, total_count, first_industry_count, second_industry_count, third_industry_count)
VALUES (#{year}, #{totalCount}, #{firstIndustryCount}, #{secondIndustryCount}, #{thirdIndustryCount})
</insert>
<insert id="update" parameterType="com.ruoyi.cms.domain.ModelDemandMonitorEmployment">
UPDATE model_demand_monitor_employment
SET year = #{year},
total_count = #{totalCount},
first_industry_count = #{firstIndustryCount},
second_industry_count = #{secondIndustryCount},
third_industry_count = #{thirdIndustryCount}
WHERE id = #{id}
</insert>
<delete id="deleteById" parameterType="java.lang.Long">
DELETE
FROM model_demand_monitor_employment
WHERE id = #{id}
</delete>
<delete id="clear">
DELETE FROM model_demand_monitor_employment
WHERE id IS NOT NULL;
</delete>
<select id="selectById" parameterType="java.lang.Long"
resultType="com.ruoyi.cms.domain.ModelDemandMonitorEmployment">
SELECT id,
year,
total_count AS totalCount,
first_industry_count AS firstIndustryCount,
second_industry_count AS secondIndustryCount,
third_industry_count AS thirdIndustryCount
FROM model_demand_monitor_employment
WHERE id = #{id}
</select>
<select id="findUnique" parameterType="com.ruoyi.cms.domain.ModelDemandMonitorEmployment"
resultType="com.ruoyi.cms.domain.ModelDemandMonitorEmployment">
SELECT id,
year,
total_count AS totalCount,
first_industry_count AS firstIndustryCount,
second_industry_count AS secondIndustryCount,
third_industry_count AS thirdIndustryCount
FROM model_demand_monitor_employment
WHERE year = #{year}
</select>
<select id="list" parameterType="com.ruoyi.cms.domain.ModelDemandMonitorEmployment"
resultType="com.ruoyi.cms.domain.ModelDemandMonitorEmployment">
SELECT id,
year,
total_count AS totalCount,
first_industry_count AS firstIndustryCount,
second_industry_count AS secondIndustryCount,
third_industry_count AS thirdIndustryCount
FROM model_demand_monitor_employment
<where>
<if test="id != null">
AND id = #{id}
</if>
<if test="year != null">
AND year = #{year}
</if>
</where>
ORDER BY year DESC
</select>
</mapper>

View File

@@ -1033,4 +1033,78 @@ COMMENT
ON COLUMN shz_data_dashboard.model_supply_monitor_occupation_population.female_count IS '女性人数';
COMMENT
ON TABLE shz_data_dashboard.model_supply_monitor_occupation_population IS '劳动力供给分职业劳动力人口';
ON TABLE shz_data_dashboard.model_supply_monitor_occupation_population IS '劳动力供给分职业劳动力人口';
--
CREATE TABLE shz_data_dashboard.model_supply_monitor_occupation_population
(
id serial PRIMARY KEY,
year integer NOT NULL,
occupation_code character varying(200) NOT NULL COLLATE pg_catalog."default",
occupation_name character varying(200) NOT NULL COLLATE pg_catalog."default",
male_count integer NOT NULL,
female_count integer NOT NULL
)
;
ALTER TABLE shz_data_dashboard.model_supply_monitor_occupation_population
OWNER TO sysdba;
COMMENT
ON COLUMN shz_data_dashboard.model_supply_monitor_occupation_population.id IS '主键';
COMMENT
ON COLUMN shz_data_dashboard.model_supply_monitor_occupation_population.year IS '年份';
COMMENT
ON COLUMN shz_data_dashboard.model_supply_monitor_occupation_population.occupation_code IS '职业编号';
COMMENT
ON COLUMN shz_data_dashboard.model_supply_monitor_occupation_population.occupation_name IS '职业名称';
COMMENT
ON COLUMN shz_data_dashboard.model_supply_monitor_occupation_population.male_count IS '男性人数';
COMMENT
ON COLUMN shz_data_dashboard.model_supply_monitor_occupation_population.female_count IS '女性人数';
COMMENT
ON TABLE shz_data_dashboard.model_supply_monitor_occupation_population IS '劳动力供给分职业劳动力人口';
--
CREATE TABLE shz_data_dashboard.model_demand_monitor_employment
(
id serial PRIMARY KEY,
year integer NOT NULL,
total_count integer NOT NULL,
first_industry_count integer NOT NULL,
second_industry_count integer NOT NULL,
third_industry_count integer NOT NULL
)
;
ALTER TABLE shz_data_dashboard.model_demand_monitor_employment
OWNER TO sysdba;
COMMENT
ON COLUMN shz_data_dashboard.model_demand_monitor_employment.id IS '主键';
COMMENT
ON COLUMN shz_data_dashboard.model_demand_monitor_employment.year IS '年份';
COMMENT
ON COLUMN shz_data_dashboard.model_demand_monitor_employment.total_count IS '总就业人数(万人)';
COMMENT
ON COLUMN shz_data_dashboard.model_demand_monitor_employment.first_industry_count IS '第一产业就业人数(万人)';
COMMENT
ON COLUMN shz_data_dashboard.model_demand_monitor_employment.second_industry_count IS '第二产业就业人数(万人)';
COMMENT
ON COLUMN shz_data_dashboard.model_demand_monitor_employment.third_industry_count IS '第三产业就业人数(万人)';
COMMENT
ON TABLE shz_data_dashboard.model_demand_monitor_employment IS '劳动力需求就业人数';