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 778ba02..a3bc796 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 @@ -36,6 +36,8 @@ public enum ModelTemplateTypeEnum { MODEL_DEMAND_MONITOR_INDUSTRY_INCREASE("劳动力动态监测系统-劳动力需求产业增加值"), MODEL_DEMAND_MONITOR_INDUSTRY_TREND("劳动力动态监测系统-劳动力需求分行业需求趋势分析"), + + MODEL_DEMAND_MONITOR_MAJOR_INDUSTRY_TREND("劳动力动态监测系统-劳动力需求重点产业需求趋势分析"), ; private final String desc; } diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/ModelDemandMonitorMajorIndustryTrendController.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/ModelDemandMonitorMajorIndustryTrendController.java new file mode 100644 index 0000000..a65abeb --- /dev/null +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/ModelDemandMonitorMajorIndustryTrendController.java @@ -0,0 +1,104 @@ +package com.ruoyi.cms.controller; + +import com.ruoyi.cms.domain.ModelDemandMonitorMajorIndustryTrend; +import com.ruoyi.cms.domain.vo.ModelDemandMonitorMajorIndustryTrendVo; +import com.ruoyi.cms.service.ModelDemandMonitorMajorIndustryTrendService; +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/demandMonitorMajorIndustryTrend") +@RequiredArgsConstructor +public class ModelDemandMonitorMajorIndustryTrendController extends BaseController { + + private final ModelDemandMonitorMajorIndustryTrendService modelDemandMonitorMajorIndustryTrendService; + + /** + * 创建 + * + * @param modelDemandMonitorMajorIndustryTrend 劳动力需求重点产业需求趋势分析 + * @return 创建结果 + */ + @PostMapping("/create") + public AjaxResult create(@Valid @RequestBody ModelDemandMonitorMajorIndustryTrend modelDemandMonitorMajorIndustryTrend) { + modelDemandMonitorMajorIndustryTrendService.create(modelDemandMonitorMajorIndustryTrend); + return AjaxResult.success(); + } + + /** + * 更新 + * + * @param modelDemandMonitorMajorIndustryTrend 劳动力需求重点产业需求趋势分析 + * @return 更新结果 + */ + @PutMapping("/update") + public AjaxResult update(@Valid @RequestBody ModelDemandMonitorMajorIndustryTrend modelDemandMonitorMajorIndustryTrend) { + modelDemandMonitorMajorIndustryTrendService.update(modelDemandMonitorMajorIndustryTrend); + return AjaxResult.success(); + } + + /** + * 删除 + * + * @param id ID + * @return 删除结果 + */ + @DeleteMapping("/delete") + public AjaxResult delete(@RequestParam Long id) { + modelDemandMonitorMajorIndustryTrendService.delete(id); + return AjaxResult.success(); + } + + /** + * 清空 + * + * @return 清空结果 + */ + @DeleteMapping("/clear") + public AjaxResult clear() { + modelDemandMonitorMajorIndustryTrendService.clear(); + return AjaxResult.success(); + } + + /** + * 查询详情 + * + * @param id ID + * @return 劳动力需求重点产业需求趋势分析 + */ + @GetMapping("/detail") + public AjaxResult detail(@RequestParam Long id) { + ModelDemandMonitorMajorIndustryTrend data = modelDemandMonitorMajorIndustryTrendService.detail(id); + return AjaxResult.success(data); + } + + /** + * 查询列表 + * + * @param modelDemandMonitorMajorIndustryTrend 劳动力需求重点产业需求趋势分析 + * @return 列表 + */ + @PostMapping("/list") + public AjaxResult list(@RequestBody ModelDemandMonitorMajorIndustryTrend modelDemandMonitorMajorIndustryTrend) { + ModelDemandMonitorMajorIndustryTrendVo list = + modelDemandMonitorMajorIndustryTrendService.listDemand(modelDemandMonitorMajorIndustryTrend); + return AjaxResult.success(list); + } +} \ No newline at end of file diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/ModelDemandMonitorMajorIndustryTrend.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/ModelDemandMonitorMajorIndustryTrend.java new file mode 100644 index 0000000..ee76dd9 --- /dev/null +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/ModelDemandMonitorMajorIndustryTrend.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 ModelDemandMonitorMajorIndustryTrend 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/vo/ModelDemandMonitorMajorIndustryTrendVo.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/vo/ModelDemandMonitorMajorIndustryTrendVo.java new file mode 100644 index 0000000..8fdf5ba --- /dev/null +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/vo/ModelDemandMonitorMajorIndustryTrendVo.java @@ -0,0 +1,29 @@ +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 ModelDemandMonitorMajorIndustryTrendVo implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 数据列表 + */ + private List dataList; +} \ No newline at end of file diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/mapper/ModelDemandMonitorMajorIndustryTrendMapper.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/mapper/ModelDemandMonitorMajorIndustryTrendMapper.java new file mode 100644 index 0000000..9ef9831 --- /dev/null +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/mapper/ModelDemandMonitorMajorIndustryTrendMapper.java @@ -0,0 +1,64 @@ +package com.ruoyi.cms.mapper; + +import com.ruoyi.cms.domain.ModelDemandMonitorMajorIndustryTrend; + +import java.util.List; + +/** + * 劳动力需求重点产业需求趋势分析 + * + * @author 马宝龙 + * @date 2026/7/3 + */ +public interface ModelDemandMonitorMajorIndustryTrendMapper { + + /** + * 新增 + * + * @param modelDemandMonitorMajorIndustryTrend 劳动力需求重点产业需求趋势分析 + */ + void insert(ModelDemandMonitorMajorIndustryTrend modelDemandMonitorMajorIndustryTrend); + + /** + * 修改 + * + * @param modelDemandMonitorMajorIndustryTrend 劳动力需求重点产业需求趋势分析 + */ + void update(ModelDemandMonitorMajorIndustryTrend modelDemandMonitorMajorIndustryTrend); + + /** + * 通过ID删除 + * + * @param id ID + */ + void deleteById(Long id); + + /** + * 清空 + */ + void clear(); + + /** + * 通过ID查询 + * + * @param id ID + * @return 劳动力需求重点产业需求趋势分析 + */ + ModelDemandMonitorMajorIndustryTrend selectById(Long id); + + /** + * 查询唯一(按年月+产业编号) + * + * @param modelDemandMonitorMajorIndustryTrend 劳动力需求重点产业需求趋势分析 + * @return 劳动力需求重点产业需求趋势分析 + */ + ModelDemandMonitorMajorIndustryTrend findUnique(ModelDemandMonitorMajorIndustryTrend modelDemandMonitorMajorIndustryTrend); + + /** + * 查询列表 + * + * @param modelDemandMonitorMajorIndustryTrend 劳动力需求重点产业需求趋势分析 + * @return 列表 + */ + List list(ModelDemandMonitorMajorIndustryTrend modelDemandMonitorMajorIndustryTrend); +} \ No newline at end of file diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/ModelDemandMonitorMajorIndustryTrendService.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/ModelDemandMonitorMajorIndustryTrendService.java new file mode 100644 index 0000000..a7c575b --- /dev/null +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/ModelDemandMonitorMajorIndustryTrendService.java @@ -0,0 +1,84 @@ +package com.ruoyi.cms.service; + +import com.ruoyi.cms.domain.ModelDemandMonitorMajorIndustryTrend; +import com.ruoyi.cms.domain.dto.ModelExportParamDto; +import com.ruoyi.cms.domain.vo.ModelDemandMonitorMajorIndustryTrendVo; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * 劳动力需求重点产业需求趋势分析 + * + * @author 马宝龙 + * @date 2026/7/3 + */ +public interface ModelDemandMonitorMajorIndustryTrendService { + + /** + * 创建 + * + * @param modelDemandMonitorMajorIndustryTrend 劳动力需求重点产业需求趋势分析 + */ + void create(ModelDemandMonitorMajorIndustryTrend modelDemandMonitorMajorIndustryTrend); + + /** + * 更新 + * + * @param modelDemandMonitorMajorIndustryTrend 劳动力需求重点产业需求趋势分析 + */ + void update(ModelDemandMonitorMajorIndustryTrend modelDemandMonitorMajorIndustryTrend); + + /** + * 删除 + * + * @param id ID + */ + void delete(Long id); + + /** + * 清空 + */ + void clear(); + + /** + * 查询详情 + * + * @param id ID + * @return 劳动力需求重点产业需求趋势分析 + */ + ModelDemandMonitorMajorIndustryTrend detail(Long id); + + /** + * 查询列表 + * + * @param modelDemandMonitorMajorIndustryTrend 劳动力需求重点产业需求趋势分析 + * @return 列表 + */ + List list(ModelDemandMonitorMajorIndustryTrend modelDemandMonitorMajorIndustryTrend); + + /** + * 查询需求列表 + * + * @param modelDemandMonitorMajorIndustryTrend 劳动力需求重点产业需求趋势分析 + * @return 需求列表 + */ + ModelDemandMonitorMajorIndustryTrendVo listDemand(ModelDemandMonitorMajorIndustryTrend modelDemandMonitorMajorIndustryTrend); + + /** + * 导入数据 + * + * @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 dd99fb2..e51e622 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 @@ -6,6 +6,7 @@ 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.ModelDemandMonitorMajorIndustryTrendService; import com.ruoyi.cms.service.ModelSupplyMonitorIndustryPopulationService; import com.ruoyi.cms.service.ModelSupplyMonitorLaborJoinRateService; import com.ruoyi.cms.service.ModelSupplyMonitorOccupationPopulationService; @@ -50,6 +51,7 @@ public class ModelCommonServiceImpl implements ModelCommonService { private final ModelDemandMonitorEmploymentService modelDemandMonitorEmploymentService; private final ModelDemandMonitorIndustryIncreaseService modelDemandMonitorIndustryIncreaseService; private final ModelDemandMonitorIndustryTrendService modelDemandMonitorIndustryTrendService; + private final ModelDemandMonitorMajorIndustryTrendService modelDemandMonitorMajorIndustryTrendService; @Override public void template(HttpServletResponse response, @@ -111,6 +113,8 @@ public class ModelCommonServiceImpl implements ModelCommonService { return modelDemandMonitorIndustryIncreaseService.importExcel(file); case MODEL_DEMAND_MONITOR_INDUSTRY_TREND: return modelDemandMonitorIndustryTrendService.importExcel(file); + case MODEL_DEMAND_MONITOR_MAJOR_INDUSTRY_TREND: + return modelDemandMonitorMajorIndustryTrendService.importExcel(file); default: throw new ServiceException("模板类型错误"); } @@ -153,6 +157,9 @@ public class ModelCommonServiceImpl implements ModelCommonService { case MODEL_DEMAND_MONITOR_INDUSTRY_TREND: modelDemandMonitorIndustryTrendService.exportExcel(response, dto); break; + case MODEL_DEMAND_MONITOR_MAJOR_INDUSTRY_TREND: + modelDemandMonitorMajorIndustryTrendService.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 index 8a07bb2..fe1d7ae 100644 --- 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 @@ -2,6 +2,7 @@ package com.ruoyi.cms.service.impl; import com.ruoyi.cms.constant.enums.ModelTemplateTypeEnum; import com.ruoyi.cms.domain.ModelDemandMonitorIndustryTrend; +import com.ruoyi.cms.domain.ModelDemandMonitorMajorIndustryTrend; import com.ruoyi.cms.domain.dto.ExcelRow; import com.ruoyi.cms.domain.dto.ModelExportParamDto; import com.ruoyi.cms.domain.vo.ModelDemandMonitorIndustryTrendVo; @@ -169,6 +170,7 @@ public class ModelDemandMonitorIndustryTrendServiceImpl implements ModelDemandMo List firstRow = new ArrayList<>(); firstRow.add("年月"); + firstRow.add("总需求人数"); for (String industryCode : industryCodeList) { firstRow.add(industryName.get(industryCode)); } @@ -181,11 +183,15 @@ public class ModelDemandMonitorIndustryTrendServiceImpl implements ModelDemandMo for (ModelDemandMonitorIndustryTrend trend : trends) { trendMap.put(trend.getIndustryCode(), trend); } + int totalDemandCount = 0; for (String industryCode : industryCodeList) { - rows.add(Optional.ofNullable(trendMap.get(industryCode)) + Integer demandCount = Optional.ofNullable(trendMap.get(industryCode)) .map(ModelDemandMonitorIndustryTrend::getDemandCount) - .orElse(0).toString()); + .orElse(0); + totalDemandCount += demandCount; + rows.add(demandCount.toString()); } + rows.add(1, Integer.toString(totalDemandCount)); dataList.add(new ExcelRow(rows.toArray(new String[0]))); } vo.setDataList(dataList); diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/ModelDemandMonitorMajorIndustryTrendServiceImpl.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/ModelDemandMonitorMajorIndustryTrendServiceImpl.java new file mode 100644 index 0000000..314ef18 --- /dev/null +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/ModelDemandMonitorMajorIndustryTrendServiceImpl.java @@ -0,0 +1,274 @@ +package com.ruoyi.cms.service.impl; + +import com.ruoyi.cms.constant.enums.ModelTemplateTypeEnum; +import com.ruoyi.cms.domain.ModelDemandMonitorMajorIndustryTrend; +import com.ruoyi.cms.domain.dto.ExcelRow; +import com.ruoyi.cms.domain.dto.ModelExportParamDto; +import com.ruoyi.cms.domain.vo.ModelDemandMonitorMajorIndustryTrendVo; +import com.ruoyi.cms.mapper.ModelDemandMonitorMajorIndustryTrendMapper; +import com.ruoyi.cms.service.ModelDemandMonitorMajorIndustryTrendService; +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 ModelDemandMonitorMajorIndustryTrendServiceImpl implements ModelDemandMonitorMajorIndustryTrendService { + + private final ModelDemandMonitorMajorIndustryTrendMapper modelDemandMonitorMajorIndustryTrendMapper; + private final Validator validator; + + @Override + public void create(ModelDemandMonitorMajorIndustryTrend modelDemandMonitorMajorIndustryTrend) { + + check(modelDemandMonitorMajorIndustryTrend); + + // 查询唯一(按年月+产业编号) + Optional optional = findUnique(modelDemandMonitorMajorIndustryTrend); + if (optional.isPresent()) { + // 更新 + ModelDemandMonitorMajorIndustryTrend exists = optional.get(); + modelDemandMonitorMajorIndustryTrend.setId(exists.getId()); + modelDemandMonitorMajorIndustryTrendMapper.update(modelDemandMonitorMajorIndustryTrend); + } else { + // 新增 + modelDemandMonitorMajorIndustryTrendMapper.insert(modelDemandMonitorMajorIndustryTrend); + } + } + + /** + * 检查 + * + * @param modelDemandMonitorMajorIndustryTrend 劳动力需求重点产业需求趋势分析 + */ + void check(ModelDemandMonitorMajorIndustryTrend modelDemandMonitorMajorIndustryTrend) { + if (StringUtils.isBlank(modelDemandMonitorMajorIndustryTrend.getYearMonth())) { + throw new ServiceException("年月不能为空"); + } + if (StringUtils.isBlank(modelDemandMonitorMajorIndustryTrend.getIndustryCode())) { + throw new ServiceException("产业编号不能为空"); + } + if (StringUtils.isBlank(modelDemandMonitorMajorIndustryTrend.getIndustryName())) { + throw new ServiceException("产业名称不能为空"); + } + if (Objects.isNull(modelDemandMonitorMajorIndustryTrend.getDemandCount())) { + throw new ServiceException("需求人数不能为空"); + } + } + + @Override + public void update(ModelDemandMonitorMajorIndustryTrend modelDemandMonitorMajorIndustryTrend) { + + check(modelDemandMonitorMajorIndustryTrend); + + if (Objects.isNull(modelDemandMonitorMajorIndustryTrend.getId())) { + throw new ServiceException("id不能为空"); + } + Optional unique = findUnique(modelDemandMonitorMajorIndustryTrend); + if (!unique.isPresent()) { + modelDemandMonitorMajorIndustryTrendMapper.update(modelDemandMonitorMajorIndustryTrend); + return; + } + ModelDemandMonitorMajorIndustryTrend exists = unique.get(); + if (!exists.getId().equals(modelDemandMonitorMajorIndustryTrend.getId())) { + throw new ServiceException("数据已存在"); + } + modelDemandMonitorMajorIndustryTrendMapper.update(modelDemandMonitorMajorIndustryTrend); + } + + @Override + public void delete(Long id) { + if (Objects.isNull(id)) { + throw new ServiceException("id不能为空"); + } + modelDemandMonitorMajorIndustryTrendMapper.deleteById(id); + } + + @Override + public void clear() { + modelDemandMonitorMajorIndustryTrendMapper.clear(); + } + + @Override + public ModelDemandMonitorMajorIndustryTrend detail(Long id) { + if (Objects.isNull(id)) { + throw new ServiceException("id不能为空"); + } + return modelDemandMonitorMajorIndustryTrendMapper.selectById(id); + } + + /** + * 查询唯一 + * + * @param modelDemandMonitorMajorIndustryTrend 劳动力需求重点产业需求趋势分析 + * @return 劳动力需求重点产业需求趋势分析 + */ + private Optional findUnique(ModelDemandMonitorMajorIndustryTrend modelDemandMonitorMajorIndustryTrend) { + ModelDemandMonitorMajorIndustryTrend unique = + modelDemandMonitorMajorIndustryTrendMapper.findUnique(modelDemandMonitorMajorIndustryTrend); + return Optional.ofNullable(unique); + } + + @Override + public List list(ModelDemandMonitorMajorIndustryTrend modelDemandMonitorMajorIndustryTrend) { + return modelDemandMonitorMajorIndustryTrendMapper.list(modelDemandMonitorMajorIndustryTrend); + } + + @Override + public ModelDemandMonitorMajorIndustryTrendVo listDemand(ModelDemandMonitorMajorIndustryTrend modelDemandMonitorMajorIndustryTrend) { + + ModelDemandMonitorMajorIndustryTrendVo vo = ModelDemandMonitorMajorIndustryTrendVo.builder().build(); + + List list = list(modelDemandMonitorMajorIndustryTrend); + if (CollectionUtils.isEmpty(list)) { + return vo; + } + Set industryCodeSet = new HashSet<>(); + Map industryName = new HashMap<>(); + Map> map = new HashMap<>(); + for (ModelDemandMonitorMajorIndustryTrend 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("年月"); + 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 (ModelDemandMonitorMajorIndustryTrend trend : trends) { + trendMap.put(trend.getIndustryCode(), trend); + } + int totalDemandCount = 0; + for (String industryCode : industryCodeList) { + Integer demandCount = Optional.ofNullable(trendMap.get(industryCode)) + .map(ModelDemandMonitorMajorIndustryTrend::getDemandCount) + .orElse(0); + totalDemandCount += demandCount; + rows.add(demandCount.toString()); + } + rows.add(1, Integer.toString(totalDemandCount)); + 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<>(ModelDemandMonitorMajorIndustryTrend.class); + List list = util.importExcel(file.getInputStream()); + + ModelDemandMonitorMajorIndustryTrend exists; + int successNum = 0; + int failureNum = 0; + StringBuilder successMsg = new StringBuilder(); + StringBuilder failureMsg = new StringBuilder(); + for (ModelDemandMonitorMajorIndustryTrend item : list) { + try { + check(item); + exists = modelDemandMonitorMajorIndustryTrendMapper.findUnique(item); + if (exists == null) { + BeanValidators.validateWithException(validator, item); + modelDemandMonitorMajorIndustryTrendMapper.insert(item); + successNum++; + String msg = + "
" + successNum + "、" + "年月:" + item.getYearMonth() + "产业:" + item.getIndustryName() + "数据导入成功。"; + successMsg.append(msg); + } else { + item.setId(exists.getId()); + BeanValidators.validateWithException(validator, item); + modelDemandMonitorMajorIndustryTrendMapper.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 { + + ModelDemandMonitorMajorIndustryTrendVo vo = listDemand(ModelDemandMonitorMajorIndustryTrend.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_MAJOR_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/ModelDemandMonitorMajorIndustryTrendMapper.xml b/ruoyi-bussiness/src/main/resources/mapper/ModelDemandMonitorMajorIndustryTrendMapper.xml new file mode 100644 index 0000000..a302b75 --- /dev/null +++ b/ruoyi-bussiness/src/main/resources/mapper/ModelDemandMonitorMajorIndustryTrendMapper.xml @@ -0,0 +1,78 @@ + + + + + + INSERT INTO model_demand_monitor_major_industry_trend (year_month, industry_code, industry_name, demand_count) + VALUES (#{yearMonth}, #{industryCode}, #{industryName}, #{demandCount}) + + + + UPDATE model_demand_monitor_major_industry_trend + SET year_month = #{yearMonth}, + industry_code = #{industryCode}, + industry_name = #{industryName}, + demand_count = #{demandCount} + WHERE id = #{id} + + + + DELETE + FROM model_demand_monitor_major_industry_trend + WHERE id = #{id} + + + + DELETE FROM model_demand_monitor_major_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..715571a 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 4202363..a729b56 100644 --- a/sql/datadashboard/table.sql +++ b/sql/datadashboard/table.sql @@ -1178,4 +1178,36 @@ 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 +ON TABLE shz_data_dashboard.model_demand_monitor_industry_trend IS '劳动力需求分行业需求趋势分析'; + +--劳动力需求重点产业需求趋势分析 +CREATE TABLE shz_data_dashboard.model_demand_monitor_major_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_major_industry_trend + OWNER TO sysdba; + +COMMENT +ON COLUMN shz_data_dashboard.model_demand_monitor_major_industry_trend.id IS '主键'; + +COMMENT +ON COLUMN shz_data_dashboard.model_demand_monitor_major_industry_trend.year_month IS '年月'; + +COMMENT +ON COLUMN shz_data_dashboard.model_demand_monitor_major_industry_trend.industry_code IS '产业编号'; + +COMMENT +ON COLUMN shz_data_dashboard.model_demand_monitor_major_industry_trend.industry_name IS '产业名称'; + +COMMENT +ON COLUMN shz_data_dashboard.model_demand_monitor_major_industry_trend.demand_count IS '需求人数'; + +COMMENT +ON TABLE shz_data_dashboard.model_demand_monitor_industry_trend IS '劳动力需求重点产业需求趋势分析'; \ No newline at end of file