添加功能
This commit is contained in:
@@ -34,6 +34,8 @@ public enum ModelTemplateTypeEnum {
|
||||
MODEL_DEMAND_MONITOR_EMPLOYMENT("劳动力动态监测系统-劳动力需求就业人数"),
|
||||
|
||||
MODEL_DEMAND_MONITOR_INDUSTRY_INCREASE("劳动力动态监测系统-劳动力需求产业增加值"),
|
||||
|
||||
MODEL_DEMAND_MONITOR_INDUSTRY_TREND("劳动力动态监测系统-劳动力需求分行业需求趋势分析"),
|
||||
;
|
||||
private final String desc;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.ruoyi.cms.controller;
|
||||
|
||||
import com.ruoyi.cms.domain.ModelDemandMonitorIndustryTrend;
|
||||
import com.ruoyi.cms.domain.vo.ModelDemandMonitorIndustryTrendVo;
|
||||
import com.ruoyi.cms.service.ModelDemandMonitorIndustryTrendService;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 劳动力需求分行业需求趋势分析
|
||||
*
|
||||
* @author 马宝龙
|
||||
* @date 2026/7/3
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/model/demandMonitorIndustryTrend")
|
||||
@RequiredArgsConstructor
|
||||
public class ModelDemandMonitorIndustryTrendController extends BaseController {
|
||||
|
||||
private final ModelDemandMonitorIndustryTrendService modelDemandMonitorIndustryTrendService;
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param modelDemandMonitorIndustryTrend 劳动力需求分行业需求趋势分析
|
||||
* @return 创建结果
|
||||
*/
|
||||
@PostMapping("/create")
|
||||
public AjaxResult create(@Valid @RequestBody ModelDemandMonitorIndustryTrend modelDemandMonitorIndustryTrend) {
|
||||
modelDemandMonitorIndustryTrendService.create(modelDemandMonitorIndustryTrend);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param modelDemandMonitorIndustryTrend 劳动力需求分行业需求趋势分析
|
||||
* @return 更新结果
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public AjaxResult update(@Valid @RequestBody ModelDemandMonitorIndustryTrend modelDemandMonitorIndustryTrend) {
|
||||
modelDemandMonitorIndustryTrendService.update(modelDemandMonitorIndustryTrend);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id ID
|
||||
* @return 删除结果
|
||||
*/
|
||||
@DeleteMapping("/delete")
|
||||
public AjaxResult delete(@RequestParam Long id) {
|
||||
modelDemandMonitorIndustryTrendService.delete(id);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空
|
||||
*
|
||||
* @return 清空结果
|
||||
*/
|
||||
@DeleteMapping("/clear")
|
||||
public AjaxResult clear() {
|
||||
modelDemandMonitorIndustryTrendService.clear();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*
|
||||
* @param id ID
|
||||
* @return 劳动力需求分行业需求趋势分析
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public AjaxResult detail(@RequestParam Long id) {
|
||||
ModelDemandMonitorIndustryTrend data = modelDemandMonitorIndustryTrendService.detail(id);
|
||||
return AjaxResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*
|
||||
* @param modelDemandMonitorIndustryTrend 劳动力需求分行业需求趋势分析
|
||||
* @return 列表
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public AjaxResult list(@RequestBody ModelDemandMonitorIndustryTrend modelDemandMonitorIndustryTrend) {
|
||||
ModelDemandMonitorIndustryTrendVo list =
|
||||
modelDemandMonitorIndustryTrendService.listDemand(modelDemandMonitorIndustryTrend);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
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 ModelDemandMonitorIndustryTrend implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 年月
|
||||
*/
|
||||
@Excel(name = "年月")
|
||||
private String yearMonth;
|
||||
/**
|
||||
* 行业编号
|
||||
*/
|
||||
@Excel(name = "行业编号")
|
||||
private String industryCode;
|
||||
/**
|
||||
* 行业名称
|
||||
*/
|
||||
@Excel(name = "行业名称")
|
||||
private String industryName;
|
||||
/**
|
||||
* 需求人数
|
||||
*/
|
||||
@Excel(name = "需求人数")
|
||||
private Integer demandCount;
|
||||
}
|
||||
@@ -30,7 +30,11 @@ public class ModelExportParamDto implements Serializable {
|
||||
*/
|
||||
private String indicatorCode;
|
||||
/**
|
||||
* 指标编码
|
||||
* 年份
|
||||
*/
|
||||
private Integer year;
|
||||
/**
|
||||
* 年月
|
||||
*/
|
||||
private String yearMonth;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.ruoyi.cms.domain.vo;
|
||||
|
||||
import com.ruoyi.cms.domain.dto.ExcelRow;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 劳动力需求分行业需求趋势分析
|
||||
*
|
||||
* @author 马宝龙
|
||||
* @date 2026/7/3
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ModelDemandMonitorIndustryTrendVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 标题列表
|
||||
*/
|
||||
// private List<String> titleList;
|
||||
|
||||
/**
|
||||
* 数据列表
|
||||
*/
|
||||
private List<ExcelRow> dataList;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.ruoyi.cms.mapper;
|
||||
|
||||
import com.ruoyi.cms.domain.ModelDemandMonitorIndustryTrend;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 劳动力需求分行业需求趋势分析
|
||||
*
|
||||
* @author 马宝龙
|
||||
* @date 2026/7/3
|
||||
*/
|
||||
public interface ModelDemandMonitorIndustryTrendMapper {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param modelDemandMonitorIndustryTrend 劳动力需求分行业需求趋势分析
|
||||
*/
|
||||
void insert(ModelDemandMonitorIndustryTrend modelDemandMonitorIndustryTrend);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param modelDemandMonitorIndustryTrend 劳动力需求分行业需求趋势分析
|
||||
*/
|
||||
void update(ModelDemandMonitorIndustryTrend modelDemandMonitorIndustryTrend);
|
||||
|
||||
/**
|
||||
* 通过ID删除
|
||||
*
|
||||
* @param id ID
|
||||
*/
|
||||
void deleteById(Long id);
|
||||
|
||||
/**
|
||||
* 清空
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* 通过ID查询
|
||||
*
|
||||
* @param id ID
|
||||
* @return 劳动力需求分行业需求趋势分析
|
||||
*/
|
||||
ModelDemandMonitorIndustryTrend selectById(Long id);
|
||||
|
||||
/**
|
||||
* 查询唯一(按年月+行业编号)
|
||||
*
|
||||
* @param modelDemandMonitorIndustryTrend 劳动力需求分行业需求趋势分析
|
||||
* @return 劳动力需求分行业需求趋势分析
|
||||
*/
|
||||
ModelDemandMonitorIndustryTrend findUnique(ModelDemandMonitorIndustryTrend modelDemandMonitorIndustryTrend);
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*
|
||||
* @param modelDemandMonitorIndustryTrend 劳动力需求分行业需求趋势分析
|
||||
* @return 列表
|
||||
*/
|
||||
List<ModelDemandMonitorIndustryTrend> list(ModelDemandMonitorIndustryTrend modelDemandMonitorIndustryTrend);
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.ruoyi.cms.service;
|
||||
|
||||
import com.ruoyi.cms.domain.ModelDemandMonitorIndustryTrend;
|
||||
import com.ruoyi.cms.domain.dto.ModelExportParamDto;
|
||||
import com.ruoyi.cms.domain.vo.ModelDemandMonitorIndustryTrendVo;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 劳动力需求分行业需求趋势分析
|
||||
*
|
||||
* @author 马宝龙
|
||||
* @date 2026/7/3
|
||||
*/
|
||||
public interface ModelDemandMonitorIndustryTrendService {
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param modelDemandMonitorIndustryTrend 劳动力需求分行业需求趋势分析
|
||||
*/
|
||||
void create(ModelDemandMonitorIndustryTrend modelDemandMonitorIndustryTrend);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param modelDemandMonitorIndustryTrend 劳动力需求分行业需求趋势分析
|
||||
*/
|
||||
void update(ModelDemandMonitorIndustryTrend modelDemandMonitorIndustryTrend);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id ID
|
||||
*/
|
||||
void delete(Long id);
|
||||
|
||||
/**
|
||||
* 清空
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*
|
||||
* @param id ID
|
||||
* @return 劳动力需求分行业需求趋势分析
|
||||
*/
|
||||
ModelDemandMonitorIndustryTrend detail(Long id);
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*
|
||||
* @param modelDemandMonitorIndustryTrend 劳动力需求分行业需求趋势分析
|
||||
* @return 列表
|
||||
*/
|
||||
List<ModelDemandMonitorIndustryTrend> list(ModelDemandMonitorIndustryTrend modelDemandMonitorIndustryTrend);
|
||||
|
||||
/**
|
||||
* 查询需求列表
|
||||
*
|
||||
* @param modelDemandMonitorIndustryTrend 劳动力需求分行业需求趋势分析
|
||||
* @return 需求列表
|
||||
*/
|
||||
ModelDemandMonitorIndustryTrendVo listDemand(ModelDemandMonitorIndustryTrend modelDemandMonitorIndustryTrend);
|
||||
|
||||
/**
|
||||
* 导入数据
|
||||
*
|
||||
* @param file 文件
|
||||
* @return 导入结果
|
||||
*/
|
||||
String importExcel(MultipartFile file);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
*
|
||||
* @param response 响应体
|
||||
* @param dto 导出参数
|
||||
*/
|
||||
void exportExcel(HttpServletResponse response, ModelExportParamDto dto);
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import com.ruoyi.cms.domain.dto.ModelExportParamDto;
|
||||
import com.ruoyi.cms.service.ModelCommonService;
|
||||
import com.ruoyi.cms.service.ModelDemandMonitorEmploymentService;
|
||||
import com.ruoyi.cms.service.ModelDemandMonitorIndustryIncreaseService;
|
||||
import com.ruoyi.cms.service.ModelDemandMonitorIndustryTrendService;
|
||||
import com.ruoyi.cms.service.ModelSupplyMonitorIndustryPopulationService;
|
||||
import com.ruoyi.cms.service.ModelSupplyMonitorLaborJoinRateService;
|
||||
import com.ruoyi.cms.service.ModelSupplyMonitorOccupationPopulationService;
|
||||
@@ -48,6 +49,7 @@ public class ModelCommonServiceImpl implements ModelCommonService {
|
||||
private final ModelSupplyMonitorOccupationPopulationService modelSupplyMonitorOccupationPopulationService;
|
||||
private final ModelDemandMonitorEmploymentService modelDemandMonitorEmploymentService;
|
||||
private final ModelDemandMonitorIndustryIncreaseService modelDemandMonitorIndustryIncreaseService;
|
||||
private final ModelDemandMonitorIndustryTrendService modelDemandMonitorIndustryTrendService;
|
||||
|
||||
@Override
|
||||
public void template(HttpServletResponse response,
|
||||
@@ -107,6 +109,8 @@ public class ModelCommonServiceImpl implements ModelCommonService {
|
||||
return modelDemandMonitorEmploymentService.importExcel(file);
|
||||
case MODEL_DEMAND_MONITOR_INDUSTRY_INCREASE:
|
||||
return modelDemandMonitorIndustryIncreaseService.importExcel(file);
|
||||
case MODEL_DEMAND_MONITOR_INDUSTRY_TREND:
|
||||
return modelDemandMonitorIndustryTrendService.importExcel(file);
|
||||
default:
|
||||
throw new ServiceException("模板类型错误");
|
||||
}
|
||||
@@ -146,6 +150,9 @@ public class ModelCommonServiceImpl implements ModelCommonService {
|
||||
case MODEL_DEMAND_MONITOR_INDUSTRY_INCREASE:
|
||||
modelDemandMonitorIndustryIncreaseService.exportExcel(response, dto);
|
||||
break;
|
||||
case MODEL_DEMAND_MONITOR_INDUSTRY_TREND:
|
||||
modelDemandMonitorIndustryTrendService.exportExcel(response, dto);
|
||||
break;
|
||||
default:
|
||||
throw new ServiceException("模板类型错误");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,268 @@
|
||||
package com.ruoyi.cms.service.impl;
|
||||
|
||||
import com.ruoyi.cms.constant.enums.ModelTemplateTypeEnum;
|
||||
import com.ruoyi.cms.domain.ModelDemandMonitorIndustryTrend;
|
||||
import com.ruoyi.cms.domain.dto.ExcelRow;
|
||||
import com.ruoyi.cms.domain.dto.ModelExportParamDto;
|
||||
import com.ruoyi.cms.domain.vo.ModelDemandMonitorIndustryTrendVo;
|
||||
import com.ruoyi.cms.mapper.ModelDemandMonitorIndustryTrendMapper;
|
||||
import com.ruoyi.cms.service.ModelDemandMonitorIndustryTrendService;
|
||||
import com.ruoyi.cms.util.document.ExcelUtil;
|
||||
import com.ruoyi.cms.util.document.MultiSheetExcelUtil;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.bean.BeanValidators;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
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.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 劳动力需求分行业需求趋势分析
|
||||
*
|
||||
* @author 马宝龙
|
||||
* @date 2026/7/3
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
public class ModelDemandMonitorIndustryTrendServiceImpl implements ModelDemandMonitorIndustryTrendService {
|
||||
|
||||
private final ModelDemandMonitorIndustryTrendMapper modelDemandMonitorIndustryTrendMapper;
|
||||
private final Validator validator;
|
||||
|
||||
@Override
|
||||
public void create(ModelDemandMonitorIndustryTrend modelDemandMonitorIndustryTrend) {
|
||||
|
||||
check(modelDemandMonitorIndustryTrend);
|
||||
|
||||
// 查询唯一(按年月+行业编号)
|
||||
Optional<ModelDemandMonitorIndustryTrend> optional = findUnique(modelDemandMonitorIndustryTrend);
|
||||
if (optional.isPresent()) {
|
||||
// 更新
|
||||
ModelDemandMonitorIndustryTrend exists = optional.get();
|
||||
modelDemandMonitorIndustryTrend.setId(exists.getId());
|
||||
modelDemandMonitorIndustryTrendMapper.update(modelDemandMonitorIndustryTrend);
|
||||
} else {
|
||||
// 新增
|
||||
modelDemandMonitorIndustryTrendMapper.insert(modelDemandMonitorIndustryTrend);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查
|
||||
*
|
||||
* @param modelDemandMonitorIndustryTrend 劳动力需求分行业需求趋势分析
|
||||
*/
|
||||
void check(ModelDemandMonitorIndustryTrend modelDemandMonitorIndustryTrend) {
|
||||
if (StringUtils.isBlank(modelDemandMonitorIndustryTrend.getYearMonth())) {
|
||||
throw new ServiceException("年月不能为空");
|
||||
}
|
||||
if (StringUtils.isBlank(modelDemandMonitorIndustryTrend.getIndustryCode())) {
|
||||
throw new ServiceException("行业编号不能为空");
|
||||
}
|
||||
if (StringUtils.isBlank(modelDemandMonitorIndustryTrend.getIndustryName())) {
|
||||
throw new ServiceException("行业名称不能为空");
|
||||
}
|
||||
if (Objects.isNull(modelDemandMonitorIndustryTrend.getDemandCount())) {
|
||||
throw new ServiceException("需求人数不能为空");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(ModelDemandMonitorIndustryTrend modelDemandMonitorIndustryTrend) {
|
||||
|
||||
check(modelDemandMonitorIndustryTrend);
|
||||
|
||||
if (Objects.isNull(modelDemandMonitorIndustryTrend.getId())) {
|
||||
throw new ServiceException("id不能为空");
|
||||
}
|
||||
Optional<ModelDemandMonitorIndustryTrend> unique = findUnique(modelDemandMonitorIndustryTrend);
|
||||
if (!unique.isPresent()) {
|
||||
modelDemandMonitorIndustryTrendMapper.update(modelDemandMonitorIndustryTrend);
|
||||
return;
|
||||
}
|
||||
ModelDemandMonitorIndustryTrend exists = unique.get();
|
||||
if (!exists.getId().equals(modelDemandMonitorIndustryTrend.getId())) {
|
||||
throw new ServiceException("数据已存在");
|
||||
}
|
||||
modelDemandMonitorIndustryTrendMapper.update(modelDemandMonitorIndustryTrend);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id) {
|
||||
if (Objects.isNull(id)) {
|
||||
throw new ServiceException("id不能为空");
|
||||
}
|
||||
modelDemandMonitorIndustryTrendMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
modelDemandMonitorIndustryTrendMapper.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelDemandMonitorIndustryTrend detail(Long id) {
|
||||
if (Objects.isNull(id)) {
|
||||
throw new ServiceException("id不能为空");
|
||||
}
|
||||
return modelDemandMonitorIndustryTrendMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询唯一
|
||||
*
|
||||
* @param modelDemandMonitorIndustryTrend 劳动力需求分行业需求趋势分析
|
||||
* @return 劳动力需求分行业需求趋势分析
|
||||
*/
|
||||
private Optional<ModelDemandMonitorIndustryTrend> findUnique(ModelDemandMonitorIndustryTrend modelDemandMonitorIndustryTrend) {
|
||||
ModelDemandMonitorIndustryTrend unique =
|
||||
modelDemandMonitorIndustryTrendMapper.findUnique(modelDemandMonitorIndustryTrend);
|
||||
return Optional.ofNullable(unique);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ModelDemandMonitorIndustryTrend> list(ModelDemandMonitorIndustryTrend modelDemandMonitorIndustryTrend) {
|
||||
return modelDemandMonitorIndustryTrendMapper.list(modelDemandMonitorIndustryTrend);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelDemandMonitorIndustryTrendVo listDemand(ModelDemandMonitorIndustryTrend modelDemandMonitorIndustryTrend) {
|
||||
|
||||
ModelDemandMonitorIndustryTrendVo vo = ModelDemandMonitorIndustryTrendVo.builder().build();
|
||||
|
||||
List<ModelDemandMonitorIndustryTrend> list = list(modelDemandMonitorIndustryTrend);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return vo;
|
||||
}
|
||||
Set<String> industryCodeSet = new HashSet<>();
|
||||
Map<String, String> industryName = new HashMap<>();
|
||||
Map<String, List<ModelDemandMonitorIndustryTrend>> map = new HashMap<>();
|
||||
for (ModelDemandMonitorIndustryTrend trend : list) {
|
||||
industryCodeSet.add(trend.getIndustryCode());
|
||||
industryName.put(trend.getIndustryCode(), trend.getIndustryName());
|
||||
List<ModelDemandMonitorIndustryTrend> trendList = Optional.ofNullable(map.get(trend.getYearMonth()))
|
||||
.orElse(new ArrayList<>());
|
||||
trendList.add(trend);
|
||||
map.put(trend.getYearMonth(), trendList);
|
||||
}
|
||||
|
||||
List<ExcelRow> dataList = new ArrayList<>();
|
||||
List<String> industryCodeList = new ArrayList<>(industryCodeSet);
|
||||
Collections.sort(industryCodeList);
|
||||
|
||||
List<String> firstRow = new ArrayList<>();
|
||||
firstRow.add("年月");
|
||||
for (String industryCode : industryCodeList) {
|
||||
firstRow.add(industryName.get(industryCode));
|
||||
}
|
||||
dataList.add(new ExcelRow(firstRow.toArray(new String[0])));
|
||||
for (Map.Entry<String, List<ModelDemandMonitorIndustryTrend>> entry : map.entrySet()) {
|
||||
List<String> rows = new ArrayList<>();
|
||||
rows.add(entry.getKey());
|
||||
List<ModelDemandMonitorIndustryTrend> trends = entry.getValue();
|
||||
Map<String, ModelDemandMonitorIndustryTrend> trendMap = new HashMap<>();
|
||||
for (ModelDemandMonitorIndustryTrend trend : trends) {
|
||||
trendMap.put(trend.getIndustryCode(), trend);
|
||||
}
|
||||
for (String industryCode : industryCodeList) {
|
||||
rows.add(Optional.ofNullable(trendMap.get(industryCode))
|
||||
.map(ModelDemandMonitorIndustryTrend::getDemandCount)
|
||||
.orElse(0).toString());
|
||||
}
|
||||
dataList.add(new ExcelRow(rows.toArray(new String[0])));
|
||||
}
|
||||
vo.setDataList(dataList);
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String importExcel(MultipartFile file) {
|
||||
try {
|
||||
ExcelUtil<ModelDemandMonitorIndustryTrend> util = new ExcelUtil<>(ModelDemandMonitorIndustryTrend.class);
|
||||
List<ModelDemandMonitorIndustryTrend> list = util.importExcel(file.getInputStream());
|
||||
|
||||
ModelDemandMonitorIndustryTrend exists;
|
||||
int successNum = 0;
|
||||
int failureNum = 0;
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder failureMsg = new StringBuilder();
|
||||
for (ModelDemandMonitorIndustryTrend item : list) {
|
||||
try {
|
||||
check(item);
|
||||
exists = modelDemandMonitorIndustryTrendMapper.findUnique(item);
|
||||
if (exists == null) {
|
||||
BeanValidators.validateWithException(validator, item);
|
||||
modelDemandMonitorIndustryTrendMapper.insert(item);
|
||||
successNum++;
|
||||
String msg =
|
||||
"<br/>" + successNum + "、" + "年月:" + item.getYearMonth() + "行业:" + item.getIndustryName() + "数据导入成功。";
|
||||
successMsg.append(msg);
|
||||
} else {
|
||||
item.setId(exists.getId());
|
||||
BeanValidators.validateWithException(validator, item);
|
||||
modelDemandMonitorIndustryTrendMapper.update(item);
|
||||
successNum++;
|
||||
String msg =
|
||||
"<br/>" + successNum + "、" + "年月:" + item.getYearMonth() + "行业:" + item.getIndustryName() + "数据更新成功。";
|
||||
successMsg.append(msg);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
failureNum++;
|
||||
String msg =
|
||||
"<br/>" + failureNum + "、" + "年月:" + item.getYearMonth() + "行业:" + item.getIndustryName() + "数据导入失败:";
|
||||
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 {
|
||||
|
||||
ModelDemandMonitorIndustryTrendVo vo = listDemand(ModelDemandMonitorIndustryTrend.builder()
|
||||
.yearMonth(dto.getYearMonth())
|
||||
.build());
|
||||
|
||||
MultiSheetExcelUtil multiSheetExcelUtil = new MultiSheetExcelUtil();
|
||||
ExcelUtil<ExcelRow> basicSituationExcelUtil = new com.ruoyi.cms.util.document.ExcelUtil<>(ExcelRow.class);
|
||||
basicSituationExcelUtil.setDataList(vo.getDataList());
|
||||
basicSituationExcelUtil.setSheetName("分行业需求趋势分析");
|
||||
multiSheetExcelUtil.addSheet(basicSituationExcelUtil);
|
||||
multiSheetExcelUtil.setFileName(ModelTemplateTypeEnum.MODEL_DEMAND_MONITOR_INDUSTRY_TREND.getDesc());
|
||||
multiSheetExcelUtil.exportExcel(response);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("数据导出失败", e);
|
||||
throw new ServiceException("数据导出失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?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.ModelDemandMonitorIndustryTrendMapper">
|
||||
|
||||
<insert id="insert" parameterType="com.ruoyi.cms.domain.ModelDemandMonitorIndustryTrend">
|
||||
INSERT INTO model_demand_monitor_industry_trend (year_month, industry_code, industry_name, demand_count)
|
||||
VALUES (#{yearMonth}, #{industryCode}, #{industryName}, #{demandCount})
|
||||
</insert>
|
||||
|
||||
<insert id="update" parameterType="com.ruoyi.cms.domain.ModelDemandMonitorIndustryTrend">
|
||||
UPDATE model_demand_monitor_industry_trend
|
||||
SET year_month = #{yearMonth},
|
||||
industry_code = #{industryCode},
|
||||
industry_name = #{industryName},
|
||||
demand_count = #{demandCount}
|
||||
WHERE id = #{id}
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById" parameterType="java.lang.Long">
|
||||
DELETE
|
||||
FROM model_demand_monitor_industry_trend
|
||||
WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="clear">
|
||||
DELETE FROM model_demand_monitor_industry_trend
|
||||
WHERE id IS NOT NULL;
|
||||
</delete>
|
||||
|
||||
<select id="selectById" parameterType="java.lang.Long"
|
||||
resultType="com.ruoyi.cms.domain.ModelDemandMonitorIndustryTrend">
|
||||
SELECT id,
|
||||
year_month AS yearMonth,
|
||||
industry_code AS industryCode,
|
||||
industry_name AS industryName,
|
||||
demand_count AS demandCount
|
||||
FROM model_demand_monitor_industry_trend
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="findUnique" parameterType="com.ruoyi.cms.domain.ModelDemandMonitorIndustryTrend"
|
||||
resultType="com.ruoyi.cms.domain.ModelDemandMonitorIndustryTrend">
|
||||
SELECT id,
|
||||
year_month AS yearMonth,
|
||||
industry_code AS industryCode,
|
||||
industry_name AS industryName,
|
||||
demand_count AS demandCount
|
||||
FROM model_demand_monitor_industry_trend
|
||||
WHERE year_month = #{yearMonth}
|
||||
AND industry_code = #{industryCode}
|
||||
</select>
|
||||
|
||||
<select id="list" parameterType="com.ruoyi.cms.domain.ModelDemandMonitorIndustryTrend"
|
||||
resultType="com.ruoyi.cms.domain.ModelDemandMonitorIndustryTrend">
|
||||
SELECT id,
|
||||
year_month AS yearMonth,
|
||||
industry_code AS industryCode,
|
||||
industry_name AS industryName,
|
||||
demand_count AS demandCount
|
||||
FROM model_demand_monitor_industry_trend
|
||||
<where>
|
||||
<if test="id != null">
|
||||
AND id = #{id}
|
||||
</if>
|
||||
<if test="yearMonth != null and yearMonth != ''">
|
||||
AND year_month = #{yearMonth}
|
||||
</if>
|
||||
<if test="industryCode != null and industryCode != ''">
|
||||
AND industry_code = #{industryCode}
|
||||
</if>
|
||||
<if test="industryName != null and industryName != ''">
|
||||
AND industry_name LIKE '%'||#{industryName}||'%'
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY year_month DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Binary file not shown.
@@ -1145,3 +1145,37 @@ ON COLUMN shz_data_dashboard.model_demand_monitor_industry_increase.third_indust
|
||||
|
||||
COMMENT
|
||||
ON TABLE shz_data_dashboard.model_demand_monitor_industry_increase IS '劳动力需求产业增加值';
|
||||
|
||||
|
||||
|
||||
--劳动力需求分行业需求趋势分析
|
||||
CREATE TABLE shz_data_dashboard.model_demand_monitor_industry_trend
|
||||
(
|
||||
id serial PRIMARY KEY,
|
||||
year_month character varying(20) NOT NULL COLLATE pg_catalog."default",
|
||||
industry_code character varying(200) NOT NULL COLLATE pg_catalog."default",
|
||||
industry_name character varying(200) NOT NULL COLLATE pg_catalog."default",
|
||||
demand_count integer NOT NULL
|
||||
)
|
||||
;
|
||||
|
||||
ALTER TABLE shz_data_dashboard.model_demand_monitor_industry_trend
|
||||
OWNER TO sysdba;
|
||||
|
||||
COMMENT
|
||||
ON COLUMN shz_data_dashboard.model_demand_monitor_industry_trend.id IS '主键';
|
||||
|
||||
COMMENT
|
||||
ON COLUMN shz_data_dashboard.model_demand_monitor_industry_trend.year_month IS '年月';
|
||||
|
||||
COMMENT
|
||||
ON COLUMN shz_data_dashboard.model_demand_monitor_industry_trend.industry_code IS '行业编号';
|
||||
|
||||
COMMENT
|
||||
ON COLUMN shz_data_dashboard.model_demand_monitor_industry_trend.industry_name IS '行业名称';
|
||||
|
||||
COMMENT
|
||||
ON COLUMN shz_data_dashboard.model_demand_monitor_industry_trend.demand_count IS '需求人数';
|
||||
|
||||
COMMENT
|
||||
ON TABLE shz_data_dashboard.model_demand_monitor_industry_trend IS '劳动力需求分行业需求趋势分析';
|
||||
Reference in New Issue
Block a user