diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/constant/enums/ModelTemplateTypeEnum.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/constant/enums/ModelTemplateTypeEnum.java index 6ce90ea..778ba02 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/constant/enums/ModelTemplateTypeEnum.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/constant/enums/ModelTemplateTypeEnum.java @@ -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; } diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/ModelDemandMonitorIndustryTrendController.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/ModelDemandMonitorIndustryTrendController.java new file mode 100644 index 0000000..bb37ef4 --- /dev/null +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/ModelDemandMonitorIndustryTrendController.java @@ -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); + } +} \ No newline at end of file diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/ModelDemandMonitorIndustryTrend.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/ModelDemandMonitorIndustryTrend.java new file mode 100644 index 0000000..47e1bd1 --- /dev/null +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/ModelDemandMonitorIndustryTrend.java @@ -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; +} \ No newline at end of file diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/dto/ModelExportParamDto.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/dto/ModelExportParamDto.java index 7f70658..a04afe0 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/dto/ModelExportParamDto.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/dto/ModelExportParamDto.java @@ -30,7 +30,11 @@ public class ModelExportParamDto implements Serializable { */ private String indicatorCode; /** - * 指标编码 + * 年份 */ private Integer year; -} + /** + * 年月 + */ + private String yearMonth; +} \ No newline at end of file diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/vo/ModelDemandMonitorIndustryTrendVo.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/vo/ModelDemandMonitorIndustryTrendVo.java new file mode 100644 index 0000000..162e4ca --- /dev/null +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/vo/ModelDemandMonitorIndustryTrendVo.java @@ -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 titleList; + + /** + * 数据列表 + */ + private List dataList; +} \ No newline at end of file diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/mapper/ModelDemandMonitorIndustryTrendMapper.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/mapper/ModelDemandMonitorIndustryTrendMapper.java new file mode 100644 index 0000000..e68c4d9 --- /dev/null +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/mapper/ModelDemandMonitorIndustryTrendMapper.java @@ -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 list(ModelDemandMonitorIndustryTrend modelDemandMonitorIndustryTrend); +} \ No newline at end of file diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/ModelDemandMonitorIndustryTrendService.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/ModelDemandMonitorIndustryTrendService.java new file mode 100644 index 0000000..51b021c --- /dev/null +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/ModelDemandMonitorIndustryTrendService.java @@ -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 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); +} \ No newline at end of file diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/ModelCommonServiceImpl.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/ModelCommonServiceImpl.java index 5e59e69..dd99fb2 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/ModelCommonServiceImpl.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/ModelCommonServiceImpl.java @@ -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("模板类型错误"); } diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/ModelDemandMonitorIndustryTrendServiceImpl.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/ModelDemandMonitorIndustryTrendServiceImpl.java new file mode 100644 index 0000000..8a07bb2 --- /dev/null +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/ModelDemandMonitorIndustryTrendServiceImpl.java @@ -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 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 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 findUnique(ModelDemandMonitorIndustryTrend modelDemandMonitorIndustryTrend) { + ModelDemandMonitorIndustryTrend unique = + modelDemandMonitorIndustryTrendMapper.findUnique(modelDemandMonitorIndustryTrend); + return Optional.ofNullable(unique); + } + + @Override + public List list(ModelDemandMonitorIndustryTrend modelDemandMonitorIndustryTrend) { + return modelDemandMonitorIndustryTrendMapper.list(modelDemandMonitorIndustryTrend); + } + + @Override + public ModelDemandMonitorIndustryTrendVo listDemand(ModelDemandMonitorIndustryTrend modelDemandMonitorIndustryTrend) { + + ModelDemandMonitorIndustryTrendVo vo = ModelDemandMonitorIndustryTrendVo.builder().build(); + + List list = list(modelDemandMonitorIndustryTrend); + if (CollectionUtils.isEmpty(list)) { + return vo; + } + Set industryCodeSet = new HashSet<>(); + Map industryName = new HashMap<>(); + Map> map = new HashMap<>(); + for (ModelDemandMonitorIndustryTrend trend : list) { + industryCodeSet.add(trend.getIndustryCode()); + industryName.put(trend.getIndustryCode(), trend.getIndustryName()); + List trendList = Optional.ofNullable(map.get(trend.getYearMonth())) + .orElse(new ArrayList<>()); + trendList.add(trend); + map.put(trend.getYearMonth(), trendList); + } + + List dataList = new ArrayList<>(); + List industryCodeList = new ArrayList<>(industryCodeSet); + Collections.sort(industryCodeList); + + List 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> entry : map.entrySet()) { + List rows = new ArrayList<>(); + rows.add(entry.getKey()); + List trends = entry.getValue(); + Map 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 util = new ExcelUtil<>(ModelDemandMonitorIndustryTrend.class); + List 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 = + "
" + successNum + "、" + "年月:" + item.getYearMonth() + "行业:" + item.getIndustryName() + "数据导入成功。"; + successMsg.append(msg); + } else { + item.setId(exists.getId()); + BeanValidators.validateWithException(validator, item); + modelDemandMonitorIndustryTrendMapper.update(item); + successNum++; + String msg = + "
" + successNum + "、" + "年月:" + item.getYearMonth() + "行业:" + item.getIndustryName() + "数据更新成功。"; + successMsg.append(msg); + } + } catch (Exception e) { + failureNum++; + String msg = + "
" + 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 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("数据导出失败"); + } + } +} \ No newline at end of file diff --git a/ruoyi-bussiness/src/main/resources/mapper/ModelDemandMonitorIndustryTrendMapper.xml b/ruoyi-bussiness/src/main/resources/mapper/ModelDemandMonitorIndustryTrendMapper.xml new file mode 100644 index 0000000..2ba93fe --- /dev/null +++ b/ruoyi-bussiness/src/main/resources/mapper/ModelDemandMonitorIndustryTrendMapper.xml @@ -0,0 +1,78 @@ + + + + + + INSERT INTO model_demand_monitor_industry_trend (year_month, industry_code, industry_name, demand_count) + VALUES (#{yearMonth}, #{industryCode}, #{industryName}, #{demandCount}) + + + + UPDATE model_demand_monitor_industry_trend + SET year_month = #{yearMonth}, + industry_code = #{industryCode}, + industry_name = #{industryName}, + demand_count = #{demandCount} + WHERE id = #{id} + + + + DELETE + FROM model_demand_monitor_industry_trend + WHERE id = #{id} + + + + DELETE FROM model_demand_monitor_industry_trend + WHERE id IS NOT NULL; + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-bussiness/src/main/resources/template/劳动力动态监测系统-劳动力需求分行业需求趋势分析.xlsx b/ruoyi-bussiness/src/main/resources/template/劳动力动态监测系统-劳动力需求分行业需求趋势分析.xlsx new file mode 100644 index 0000000..9250fbe Binary files /dev/null and b/ruoyi-bussiness/src/main/resources/template/劳动力动态监测系统-劳动力需求分行业需求趋势分析.xlsx differ diff --git a/sql/datadashboard/table.sql b/sql/datadashboard/table.sql index abe03b3..4202363 100644 --- a/sql/datadashboard/table.sql +++ b/sql/datadashboard/table.sql @@ -1077,7 +1077,7 @@ 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, + year integer NOT NULL, total_count numeric(10, 2) NOT NULL, first_industry_count numeric(10, 2) NOT NULL, second_industry_count numeric(10, 2) NOT NULL, @@ -1113,8 +1113,8 @@ ON TABLE shz_data_dashboard.model_demand_monitor_employment IS '劳动力需 --劳动力需求产业增加值 CREATE TABLE shz_data_dashboard.model_demand_monitor_industry_increase ( - id serial PRIMARY KEY, - year integer NOT NULL, + id serial PRIMARY KEY, + year integer NOT NULL, total_amount numeric(10, 2) NOT NULL, first_industry_amount numeric(10, 2) NOT NULL, second_industry_amount numeric(10, 2) NOT NULL, @@ -1144,4 +1144,38 @@ COMMENT ON COLUMN shz_data_dashboard.model_demand_monitor_industry_increase.third_industry_amount IS '第三产业增加值(亿元)'; COMMENT -ON TABLE shz_data_dashboard.model_demand_monitor_industry_increase IS '劳动力需求产业增加值'; \ No newline at end of file +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 '劳动力需求分行业需求趋势分析'; \ No newline at end of file