添加功能
This commit is contained in:
@@ -32,6 +32,8 @@ public enum ModelTemplateTypeEnum {
|
||||
MODEL_SUPPLY_MONITOR_OCCUPATION_POPULATION_RESULT("劳动力动态监测系统-劳动力供给结果分职业劳动力人口"),
|
||||
|
||||
MODEL_DEMAND_MONITOR_EMPLOYMENT("劳动力动态监测系统-劳动力需求就业人数"),
|
||||
|
||||
MODEL_DEMAND_MONITOR_INDUSTRY_INCREASE("劳动力动态监测系统-劳动力需求产业增加值"),
|
||||
;
|
||||
private final String desc;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.ruoyi.cms.controller;
|
||||
|
||||
import com.ruoyi.cms.domain.ModelDemandMonitorIndustryIncrease;
|
||||
import com.ruoyi.cms.service.ModelDemandMonitorIndustryIncreaseService;
|
||||
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/demandMonitorIndustryIncrease")
|
||||
@RequiredArgsConstructor
|
||||
public class ModelDemandMonitorIndustryIncreaseController extends BaseController {
|
||||
|
||||
private final ModelDemandMonitorIndustryIncreaseService modelDemandMonitorIndustryIncreaseService;
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param modelDemandMonitorIndustryIncrease 劳动力需求产业增加值
|
||||
* @return 创建结果
|
||||
*/
|
||||
@PostMapping("/create")
|
||||
public AjaxResult create(@Valid @RequestBody ModelDemandMonitorIndustryIncrease modelDemandMonitorIndustryIncrease) {
|
||||
modelDemandMonitorIndustryIncreaseService.create(modelDemandMonitorIndustryIncrease);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param modelDemandMonitorIndustryIncrease 劳动力需求产业增加值
|
||||
* @return 更新结果
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public AjaxResult update(@Valid @RequestBody ModelDemandMonitorIndustryIncrease modelDemandMonitorIndustryIncrease) {
|
||||
modelDemandMonitorIndustryIncreaseService.update(modelDemandMonitorIndustryIncrease);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id ID
|
||||
* @return 删除结果
|
||||
*/
|
||||
@DeleteMapping("/delete")
|
||||
public AjaxResult delete(@RequestParam Long id) {
|
||||
modelDemandMonitorIndustryIncreaseService.delete(id);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空
|
||||
*
|
||||
* @return 清空结果
|
||||
*/
|
||||
@DeleteMapping("/clear")
|
||||
public AjaxResult clear() {
|
||||
modelDemandMonitorIndustryIncreaseService.clear();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*
|
||||
* @param id ID
|
||||
* @return 劳动力需求产业增加值
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public AjaxResult detail(@RequestParam Long id) {
|
||||
ModelDemandMonitorIndustryIncrease data = modelDemandMonitorIndustryIncreaseService.detail(id);
|
||||
return AjaxResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*
|
||||
* @param modelDemandMonitorIndustryIncrease 劳动力需求产业增加值
|
||||
* @return 列表
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public AjaxResult list(@RequestBody ModelDemandMonitorIndustryIncrease modelDemandMonitorIndustryIncrease) {
|
||||
List<ModelDemandMonitorIndustryIncrease> list =
|
||||
modelDemandMonitorIndustryIncreaseService.list(modelDemandMonitorIndustryIncrease);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 劳动力需求就业人数
|
||||
@@ -34,20 +35,20 @@ public class ModelDemandMonitorEmployment implements Serializable {
|
||||
* 总就业人数(万人)
|
||||
*/
|
||||
@Excel(name = "总就业人数(万人)")
|
||||
private Integer totalCount;
|
||||
private BigDecimal totalCount;
|
||||
/**
|
||||
* 第一产业就业人数(万人)
|
||||
*/
|
||||
@Excel(name = "第一产业就业人数(万人)")
|
||||
private Integer firstIndustryCount;
|
||||
private BigDecimal firstIndustryCount;
|
||||
/**
|
||||
* 第二产业就业人数(万人)
|
||||
*/
|
||||
@Excel(name = "第二产业就业人数(万人)")
|
||||
private Integer secondIndustryCount;
|
||||
private BigDecimal secondIndustryCount;
|
||||
/**
|
||||
* 第三产业就业人数(万人)
|
||||
*/
|
||||
@Excel(name = "第三产业就业人数(万人)")
|
||||
private Integer thirdIndustryCount;
|
||||
private BigDecimal thirdIndustryCount;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
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;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 劳动力需求产业增加值
|
||||
*
|
||||
* @author 马宝龙
|
||||
* @date 2026/7/3
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ModelDemandMonitorIndustryIncrease implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 年份
|
||||
*/
|
||||
@Excel(name = "年份")
|
||||
private Integer year;
|
||||
/**
|
||||
* 生产总值(亿元)
|
||||
*/
|
||||
@Excel(name = "生产总值(亿元)")
|
||||
private BigDecimal totalAmount;
|
||||
/**
|
||||
* 第一产业增加值(亿元)
|
||||
*/
|
||||
@Excel(name = "第一产业增加值(亿元)")
|
||||
private BigDecimal firstIndustryAmount;
|
||||
/**
|
||||
* 第二产业增加值(亿元)
|
||||
*/
|
||||
@Excel(name = "第二产业增加值(亿元)")
|
||||
private BigDecimal secondIndustryAmount;
|
||||
/**
|
||||
* 第三产业增加值(亿元)
|
||||
*/
|
||||
@Excel(name = "第三产业增加值(亿元)")
|
||||
private BigDecimal thirdIndustryAmount;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.ruoyi.cms.mapper;
|
||||
|
||||
import com.ruoyi.cms.domain.ModelDemandMonitorIndustryIncrease;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 劳动力需求产业增加值
|
||||
*
|
||||
* @author 马宝龙
|
||||
* @date 2026/7/3
|
||||
*/
|
||||
public interface ModelDemandMonitorIndustryIncreaseMapper {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param modelDemandMonitorIndustryIncrease 劳动力需求产业增加值
|
||||
*/
|
||||
void insert(ModelDemandMonitorIndustryIncrease modelDemandMonitorIndustryIncrease);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param modelDemandMonitorIndustryIncrease 劳动力需求产业增加值
|
||||
*/
|
||||
void update(ModelDemandMonitorIndustryIncrease modelDemandMonitorIndustryIncrease);
|
||||
|
||||
/**
|
||||
* 通过ID删除
|
||||
*
|
||||
* @param id ID
|
||||
*/
|
||||
void deleteById(Long id);
|
||||
|
||||
/**
|
||||
* 清空
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* 通过ID查询
|
||||
*
|
||||
* @param id ID
|
||||
* @return 劳动力需求产业增加值
|
||||
*/
|
||||
ModelDemandMonitorIndustryIncrease selectById(Long id);
|
||||
|
||||
/**
|
||||
* 查询唯一(按年份)
|
||||
*
|
||||
* @param modelDemandMonitorIndustryIncrease 劳动力需求产业增加值
|
||||
* @return 劳动力需求产业增加值
|
||||
*/
|
||||
ModelDemandMonitorIndustryIncrease findUnique(ModelDemandMonitorIndustryIncrease modelDemandMonitorIndustryIncrease);
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*
|
||||
* @param modelDemandMonitorIndustryIncrease 劳动力需求产业增加值
|
||||
* @return 列表
|
||||
*/
|
||||
List<ModelDemandMonitorIndustryIncrease> list(ModelDemandMonitorIndustryIncrease modelDemandMonitorIndustryIncrease);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.ruoyi.cms.service;
|
||||
|
||||
import com.ruoyi.cms.domain.ModelDemandMonitorIndustryIncrease;
|
||||
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 ModelDemandMonitorIndustryIncreaseService {
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param modelDemandMonitorIndustryIncrease 劳动力需求产业增加值
|
||||
*/
|
||||
void create(ModelDemandMonitorIndustryIncrease modelDemandMonitorIndustryIncrease);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param modelDemandMonitorIndustryIncrease 劳动力需求产业增加值
|
||||
*/
|
||||
void update(ModelDemandMonitorIndustryIncrease modelDemandMonitorIndustryIncrease);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id ID
|
||||
*/
|
||||
void delete(Long id);
|
||||
|
||||
/**
|
||||
* 清空
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*
|
||||
* @param id ID
|
||||
* @return 劳动力需求产业增加值
|
||||
*/
|
||||
ModelDemandMonitorIndustryIncrease detail(Long id);
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*
|
||||
* @param modelDemandMonitorIndustryIncrease 劳动力需求产业增加值
|
||||
* @return 列表
|
||||
*/
|
||||
List<ModelDemandMonitorIndustryIncrease> list(ModelDemandMonitorIndustryIncrease modelDemandMonitorIndustryIncrease);
|
||||
|
||||
/**
|
||||
* 导入数据
|
||||
*
|
||||
* @param file 文件
|
||||
* @return 导入结果
|
||||
*/
|
||||
String importExcel(MultipartFile file);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
*
|
||||
* @param response 响应体
|
||||
* @param dto 导出参数
|
||||
*/
|
||||
void exportExcel(HttpServletResponse response, ModelExportParamDto dto);
|
||||
}
|
||||
@@ -4,6 +4,7 @@ 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.ModelDemandMonitorIndustryIncreaseService;
|
||||
import com.ruoyi.cms.service.ModelSupplyMonitorIndustryPopulationService;
|
||||
import com.ruoyi.cms.service.ModelSupplyMonitorLaborJoinRateService;
|
||||
import com.ruoyi.cms.service.ModelSupplyMonitorOccupationPopulationService;
|
||||
@@ -46,6 +47,7 @@ public class ModelCommonServiceImpl implements ModelCommonService {
|
||||
private final ModelSupplyMonitorIndustryPopulationService modelSupplyMonitorIndustryPopulationService;
|
||||
private final ModelSupplyMonitorOccupationPopulationService modelSupplyMonitorOccupationPopulationService;
|
||||
private final ModelDemandMonitorEmploymentService modelDemandMonitorEmploymentService;
|
||||
private final ModelDemandMonitorIndustryIncreaseService modelDemandMonitorIndustryIncreaseService;
|
||||
|
||||
@Override
|
||||
public void template(HttpServletResponse response,
|
||||
@@ -103,6 +105,8 @@ public class ModelCommonServiceImpl implements ModelCommonService {
|
||||
return modelSupplyMonitorOccupationPopulationService.importExcel(file);
|
||||
case MODEL_DEMAND_MONITOR_EMPLOYMENT:
|
||||
return modelDemandMonitorEmploymentService.importExcel(file);
|
||||
case MODEL_DEMAND_MONITOR_INDUSTRY_INCREASE:
|
||||
return modelDemandMonitorIndustryIncreaseService.importExcel(file);
|
||||
default:
|
||||
throw new ServiceException("模板类型错误");
|
||||
}
|
||||
@@ -139,6 +143,9 @@ public class ModelCommonServiceImpl implements ModelCommonService {
|
||||
case MODEL_DEMAND_MONITOR_EMPLOYMENT:
|
||||
modelDemandMonitorEmploymentService.exportExcel(response, dto);
|
||||
break;
|
||||
case MODEL_DEMAND_MONITOR_INDUSTRY_INCREASE:
|
||||
modelDemandMonitorIndustryIncreaseService.exportExcel(response, dto);
|
||||
break;
|
||||
default:
|
||||
throw new ServiceException("模板类型错误");
|
||||
}
|
||||
|
||||
@@ -74,10 +74,10 @@ public class ModelDemandMonitorEmploymentServiceImpl implements ModelDemandMonit
|
||||
if (Objects.isNull(modelDemandMonitorEmployment.getThirdIndustryCount())) {
|
||||
throw new ServiceException("第三产业就业人数不能为空");
|
||||
}
|
||||
if (modelDemandMonitorEmployment.getTotalCount() !=
|
||||
(modelDemandMonitorEmployment.getFirstIndustryCount() +
|
||||
modelDemandMonitorEmployment.getSecondIndustryCount() +
|
||||
modelDemandMonitorEmployment.getThirdIndustryCount())) {
|
||||
if (modelDemandMonitorEmployment.getTotalCount().compareTo(
|
||||
(modelDemandMonitorEmployment.getFirstIndustryCount()
|
||||
.add(modelDemandMonitorEmployment.getSecondIndustryCount())
|
||||
.add(modelDemandMonitorEmployment.getThirdIndustryCount()))) != 0) {
|
||||
throw new ServiceException("总就业人数和第一产业就业人数、第二产业就业人数、第三产业就业人数不相等");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
package com.ruoyi.cms.service.impl;
|
||||
|
||||
import com.ruoyi.cms.constant.enums.ModelTemplateTypeEnum;
|
||||
import com.ruoyi.cms.domain.ModelDemandMonitorIndustryIncrease;
|
||||
import com.ruoyi.cms.domain.dto.ModelExportParamDto;
|
||||
import com.ruoyi.cms.mapper.ModelDemandMonitorIndustryIncreaseMapper;
|
||||
import com.ruoyi.cms.service.ModelDemandMonitorIndustryIncreaseService;
|
||||
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 ModelDemandMonitorIndustryIncreaseServiceImpl implements ModelDemandMonitorIndustryIncreaseService {
|
||||
|
||||
private final ModelDemandMonitorIndustryIncreaseMapper modelDemandMonitorIndustryIncreaseMapper;
|
||||
private final Validator validator;
|
||||
|
||||
@Override
|
||||
public void create(ModelDemandMonitorIndustryIncrease modelDemandMonitorIndustryIncrease) {
|
||||
|
||||
check(modelDemandMonitorIndustryIncrease);
|
||||
|
||||
// 查询唯一(按年份)
|
||||
Optional<ModelDemandMonitorIndustryIncrease> optional = findUnique(modelDemandMonitorIndustryIncrease);
|
||||
if (optional.isPresent()) {
|
||||
// 更新
|
||||
ModelDemandMonitorIndustryIncrease exists = optional.get();
|
||||
modelDemandMonitorIndustryIncrease.setId(exists.getId());
|
||||
modelDemandMonitorIndustryIncreaseMapper.update(modelDemandMonitorIndustryIncrease);
|
||||
} else {
|
||||
// 新增
|
||||
modelDemandMonitorIndustryIncreaseMapper.insert(modelDemandMonitorIndustryIncrease);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查
|
||||
*
|
||||
* @param modelDemandMonitorIndustryIncrease 劳动力需求产业增加值
|
||||
*/
|
||||
void check(ModelDemandMonitorIndustryIncrease modelDemandMonitorIndustryIncrease) {
|
||||
if (Objects.isNull(modelDemandMonitorIndustryIncrease.getYear())) {
|
||||
throw new ServiceException("年份不能为空");
|
||||
}
|
||||
if (Objects.isNull(modelDemandMonitorIndustryIncrease.getTotalAmount())) {
|
||||
throw new ServiceException("生产总值不能为空");
|
||||
}
|
||||
if (Objects.isNull(modelDemandMonitorIndustryIncrease.getFirstIndustryAmount())) {
|
||||
throw new ServiceException("第一产业增加值不能为空");
|
||||
}
|
||||
if (Objects.isNull(modelDemandMonitorIndustryIncrease.getSecondIndustryAmount())) {
|
||||
throw new ServiceException("第二产业增加值不能为空");
|
||||
}
|
||||
if (Objects.isNull(modelDemandMonitorIndustryIncrease.getThirdIndustryAmount())) {
|
||||
throw new ServiceException("第三产业增加值不能为空");
|
||||
}
|
||||
if (modelDemandMonitorIndustryIncrease.getTotalAmount().compareTo(
|
||||
(modelDemandMonitorIndustryIncrease.getFirstIndustryAmount()
|
||||
.add(modelDemandMonitorIndustryIncrease.getSecondIndustryAmount())
|
||||
.add(modelDemandMonitorIndustryIncrease.getThirdIndustryAmount()))) != 0) {
|
||||
throw new ServiceException("生产总值和第一产业增加值、第二产业增加值、第三产业增加值之和不相等");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(ModelDemandMonitorIndustryIncrease modelDemandMonitorIndustryIncrease) {
|
||||
|
||||
check(modelDemandMonitorIndustryIncrease);
|
||||
|
||||
if (Objects.isNull(modelDemandMonitorIndustryIncrease.getId())) {
|
||||
throw new ServiceException("id不能为空");
|
||||
}
|
||||
Optional<ModelDemandMonitorIndustryIncrease> unique = findUnique(modelDemandMonitorIndustryIncrease);
|
||||
if (!unique.isPresent()) {
|
||||
modelDemandMonitorIndustryIncreaseMapper.update(modelDemandMonitorIndustryIncrease);
|
||||
return;
|
||||
}
|
||||
ModelDemandMonitorIndustryIncrease exists = unique.get();
|
||||
if (!exists.getId().equals(modelDemandMonitorIndustryIncrease.getId())) {
|
||||
throw new ServiceException("数据已存在");
|
||||
}
|
||||
modelDemandMonitorIndustryIncreaseMapper.update(modelDemandMonitorIndustryIncrease);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id) {
|
||||
if (Objects.isNull(id)) {
|
||||
throw new ServiceException("id不能为空");
|
||||
}
|
||||
modelDemandMonitorIndustryIncreaseMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
modelDemandMonitorIndustryIncreaseMapper.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelDemandMonitorIndustryIncrease detail(Long id) {
|
||||
if (Objects.isNull(id)) {
|
||||
throw new ServiceException("id不能为空");
|
||||
}
|
||||
return modelDemandMonitorIndustryIncreaseMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询唯一
|
||||
*
|
||||
* @param modelDemandMonitorIndustryIncrease 劳动力需求产业增加值
|
||||
* @return 劳动力需求产业增加值
|
||||
*/
|
||||
private Optional<ModelDemandMonitorIndustryIncrease> findUnique(ModelDemandMonitorIndustryIncrease modelDemandMonitorIndustryIncrease) {
|
||||
ModelDemandMonitorIndustryIncrease unique =
|
||||
modelDemandMonitorIndustryIncreaseMapper.findUnique(modelDemandMonitorIndustryIncrease);
|
||||
return Optional.ofNullable(unique);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ModelDemandMonitorIndustryIncrease> list(ModelDemandMonitorIndustryIncrease modelDemandMonitorIndustryIncrease) {
|
||||
return modelDemandMonitorIndustryIncreaseMapper.list(modelDemandMonitorIndustryIncrease);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String importExcel(MultipartFile file) {
|
||||
try {
|
||||
ExcelUtil<ModelDemandMonitorIndustryIncrease> util = new ExcelUtil<>(ModelDemandMonitorIndustryIncrease.class);
|
||||
List<ModelDemandMonitorIndustryIncrease> list = util.importExcel(file.getInputStream());
|
||||
|
||||
ModelDemandMonitorIndustryIncrease exists;
|
||||
int successNum = 0;
|
||||
int failureNum = 0;
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder failureMsg = new StringBuilder();
|
||||
for (ModelDemandMonitorIndustryIncrease item : list) {
|
||||
try {
|
||||
check(item);
|
||||
exists = modelDemandMonitorIndustryIncreaseMapper.findUnique(item);
|
||||
if (exists == null) {
|
||||
BeanValidators.validateWithException(validator, item);
|
||||
modelDemandMonitorIndustryIncreaseMapper.insert(item);
|
||||
successNum++;
|
||||
String msg =
|
||||
"<br/>" + successNum + "、" + "年份:" + item.getYear() + "数据导入成功。";
|
||||
successMsg.append(msg);
|
||||
} else {
|
||||
item.setId(exists.getId());
|
||||
BeanValidators.validateWithException(validator, item);
|
||||
modelDemandMonitorIndustryIncreaseMapper.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<ModelDemandMonitorIndustryIncrease> list = list(ModelDemandMonitorIndustryIncrease.builder()
|
||||
.year(dto.getYear())
|
||||
.build());
|
||||
ExcelUtil<ModelDemandMonitorIndustryIncrease> util = new ExcelUtil<>(ModelDemandMonitorIndustryIncrease.class);
|
||||
util.exportExcel(response, list, ModelTemplateTypeEnum.MODEL_DEMAND_MONITOR_INDUSTRY_INCREASE.getDesc());
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("数据导出失败", e);
|
||||
throw new ServiceException("数据导出失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user