|
@@ -1,7 +1,6 @@
|
|
|
|
|
|
|
|
package org.sky.scientific.controller;
|
|
package org.sky.scientific.controller;
|
|
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
@@ -13,8 +12,10 @@ import org.sky.core.boot.ctrl.KdController;
|
|
|
import org.sky.core.log.exception.ServiceException;
|
|
import org.sky.core.log.exception.ServiceException;
|
|
|
import org.sky.core.tool.api.R;
|
|
import org.sky.core.tool.api.R;
|
|
|
import org.sky.core.tool.utils.Func;
|
|
import org.sky.core.tool.utils.Func;
|
|
|
-import org.sky.scientific.mapper.DepartmentMapper;
|
|
|
|
|
import org.sky.scientific.pojo.entity.DepartmentEntity;
|
|
import org.sky.scientific.pojo.entity.DepartmentEntity;
|
|
|
|
|
+import org.sky.scientific.pojo.entity.EnterpriseInfoEntity;
|
|
|
|
|
+import org.sky.scientific.service.IDepartmentService;
|
|
|
|
|
+import org.sky.scientific.service.IEnterpriseInfoService;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -30,55 +31,63 @@ import java.util.List;
|
|
|
@Tag(name = "企业基础信息管理")
|
|
@Tag(name = "企业基础信息管理")
|
|
|
public class EnterpriseController extends KdController {
|
|
public class EnterpriseController extends KdController {
|
|
|
|
|
|
|
|
- private final DepartmentMapper departmentMapper;
|
|
|
|
|
|
|
+ private final IDepartmentService departmentService;
|
|
|
|
|
|
|
|
- @GetMapping("/department/list")
|
|
|
|
|
|
|
+ private final IEnterpriseInfoService enterpriseInfoService;
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("enterpriseInfo/detail/{yearAndMonth}")
|
|
|
@ApiOperationSupport(order = 1)
|
|
@ApiOperationSupport(order = 1)
|
|
|
|
|
+ @Operation(summary = "企业基础信息表-获取指定年份的企业信息")
|
|
|
|
|
+ public R<EnterpriseInfoEntity> enterpriseDetail(@PathVariable("yearAndMonth") String yearAndMonth) {
|
|
|
|
|
+ EnterpriseInfoEntity detail = enterpriseInfoService.getOne(Wrappers.<EnterpriseInfoEntity>lambdaQuery().eq(EnterpriseInfoEntity::getYearAndMonth, yearAndMonth));
|
|
|
|
|
+ return R.data(detail);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("enterpriseInfo/submit")
|
|
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
|
|
+ @Operation(summary = "企业基础信息表-新增或修改", description = "传入enterpriseInfo")
|
|
|
|
|
+ public R submitEnterprise(@Valid @RequestBody EnterpriseInfoEntity enterpriseInfo) {
|
|
|
|
|
+ return R.status(enterpriseInfoService.submit(enterpriseInfo));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("enterpriseInfo/fetchLastYearData")
|
|
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
|
|
+ @Operation(summary = "企业基础信息表-读取上年度数据")
|
|
|
|
|
+ public R<Boolean> fetchEnterpriseLastYearData(EnterpriseInfoEntity enterpriseInfo) {
|
|
|
|
|
+ return R.status(enterpriseInfoService.fetchLastYearData(enterpriseInfo));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/department/list")
|
|
|
|
|
+ @ApiOperationSupport(order = 10)
|
|
|
@Operation(summary = "二级单位/部门-列表")
|
|
@Operation(summary = "二级单位/部门-列表")
|
|
|
public R<List<DepartmentEntity>> departmentList(DepartmentEntity dto) {
|
|
public R<List<DepartmentEntity>> departmentList(DepartmentEntity dto) {
|
|
|
if (Func.isBlank(dto.getYearAndMonth())) {
|
|
if (Func.isBlank(dto.getYearAndMonth())) {
|
|
|
throw new ServiceException("参数yearAndMonth不能为空");
|
|
throw new ServiceException("参数yearAndMonth不能为空");
|
|
|
}
|
|
}
|
|
|
- List<DepartmentEntity> list = departmentMapper.selectList(Wrappers.<DepartmentEntity>lambdaQuery()
|
|
|
|
|
- .eq(DepartmentEntity::getYearAndMonth, dto.getYearAndMonth()));
|
|
|
|
|
|
|
+ List<DepartmentEntity> list = departmentService.selectDepartmentList(dto.getYearAndMonth());
|
|
|
return R.data(list);
|
|
return R.data(list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@PostMapping("/department/submit")
|
|
@PostMapping("/department/submit")
|
|
|
- @ApiOperationSupport(order = 6)
|
|
|
|
|
|
|
+ @ApiOperationSupport(order = 12)
|
|
|
@Operation(summary = "二级单位/部门-新增或修改")
|
|
@Operation(summary = "二级单位/部门-新增或修改")
|
|
|
- public R submit(@Valid @RequestBody DepartmentEntity department) {
|
|
|
|
|
- LambdaQueryWrapper<DepartmentEntity> wrapper = Wrappers.<DepartmentEntity>lambdaQuery()
|
|
|
|
|
- .eq(DepartmentEntity::getName, department.getName())
|
|
|
|
|
- .eq(DepartmentEntity::getYearAndMonth, department.getYearAndMonth());
|
|
|
|
|
- DepartmentEntity dbEntity = departmentMapper.selectOne(wrapper);
|
|
|
|
|
- if (department.getId() == null) {
|
|
|
|
|
- //新增
|
|
|
|
|
- if (dbEntity != null) {
|
|
|
|
|
- throw new ServiceException("名称[" + department.getName() + "]已存在");
|
|
|
|
|
- }
|
|
|
|
|
- departmentMapper.insert(department);
|
|
|
|
|
- } else {
|
|
|
|
|
- //修改
|
|
|
|
|
- if (dbEntity!=null && Func.equals(department.getName(), dbEntity.getName()) && !Func.equals(dbEntity.getId(), department.getId())) {
|
|
|
|
|
- throw new ServiceException("名称[" + department.getName() + "]已存在");
|
|
|
|
|
- }
|
|
|
|
|
- departmentMapper.updateById(department);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ public R submitDepartment(@Valid @RequestBody DepartmentEntity department) {
|
|
|
|
|
|
|
|
- boolean result = departmentMapper.insertOrUpdate(department);
|
|
|
|
|
- return R.status(result);
|
|
|
|
|
|
|
+ return R.status(departmentService.submit(department));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @DeleteMapping("/remove")
|
|
|
|
|
|
|
+ @GetMapping("/fetchLastYearData")
|
|
|
|
|
+ @ApiOperationSupport(order = 14)
|
|
|
|
|
+ @Operation(summary = "二级单位/部门-删除-读取上年度数据")
|
|
|
|
|
+ public R<Boolean> fetchLastYearData(DepartmentEntity department) {
|
|
|
|
|
+ return R.status(departmentService.fetchLastYearData(department));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @DeleteMapping("department/remove")
|
|
|
@Operation(summary = "二级单位/部门-删除")
|
|
@Operation(summary = "二级单位/部门-删除")
|
|
|
- public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
|
|
|
|
- for (Long id : Func.toLongList(ids)) {
|
|
|
|
|
- Long count = departmentMapper.selectCount(Wrappers.<DepartmentEntity>lambdaQuery().eq(DepartmentEntity::getParentId, id));
|
|
|
|
|
- if (count > 0) {
|
|
|
|
|
- throw new ServiceException("请先删除下级部门");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return R.status(departmentMapper.deleteByIds(Func.toLongList(ids)) > 0);
|
|
|
|
|
|
|
+ @ApiOperationSupport(order = 18)
|
|
|
|
|
+ public R removeDepartment(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
|
|
|
|
+ return R.status(departmentService.deleteByIds(Func.toLongList(ids)));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
}
|
|
}
|