Commit edf09961 authored by 周昊's avatar 周昊

1、开发接口添加固有风险

parent 6ca61ccc
package com.censoft.censoftrongtong.controller; package com.censoft.censoftrongtong.controller;
import com.censoft.censoftrongtong.domain.*; import com.censoft.censoftrongtong.domain.*;
import com.censoft.censoftrongtong.domain.dto.RiskInherentListSaveDto;
import com.censoft.censoftrongtong.domain.dto.RiskPlanAppDetailsDto; import com.censoft.censoftrongtong.domain.dto.RiskPlanAppDetailsDto;
import com.censoft.censoftrongtong.domain.dto.RiskPlanAppInherentListDto; import com.censoft.censoftrongtong.domain.dto.RiskPlanAppInherentListDto;
import com.censoft.censoftrongtong.domain.dto.RiskPlanAppListDto; import com.censoft.censoftrongtong.domain.dto.RiskPlanAppListDto;
import com.censoft.censoftrongtong.enums.RiskPlanStatusType; import com.censoft.censoftrongtong.enums.RiskPlanStatusType;
import com.censoft.censoftrongtong.service.*; import com.censoft.censoftrongtong.service.*;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.service.ISysUploadFileService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
...@@ -46,6 +52,15 @@ public class RiskPlanAppController extends BaseController { ...@@ -46,6 +52,15 @@ public class RiskPlanAppController extends BaseController {
@Resource @Resource
private IRiskPlanInherentListService riskPlanInherentListService; private IRiskPlanInherentListService riskPlanInherentListService;
@Resource
private ISysUploadFileService uploadFileService;
/**
* 服务器地址
*/
@Value("${ruoyi.serverAddress}")
private String serverAddress;
/** /**
* 获取自身部门及以下的项目 * 获取自身部门及以下的项目
* *
...@@ -53,7 +68,7 @@ public class RiskPlanAppController extends BaseController { ...@@ -53,7 +68,7 @@ public class RiskPlanAppController extends BaseController {
* @real_return {@link R<List<LedgerProject>>} * @real_return {@link R<List<LedgerProject>>}
*/ */
@GetMapping("/project/list") @GetMapping("/project/list")
public R<List<LedgerProject>> getProjectList(LedgerProject ledgerProject){ public R<List<LedgerProject>> getProjectList(LedgerProject ledgerProject) {
//添加自身及以下部门筛选 //添加自身及以下部门筛选
ledgerProject.setDeptId(getLoginUser().getDeptId()); ledgerProject.setDeptId(getLoginUser().getDeptId());
return R.ok(ledgerProjectService.getProjectListByDeptId(ledgerProject)); return R.ok(ledgerProjectService.getProjectListByDeptId(ledgerProject));
...@@ -63,12 +78,12 @@ public class RiskPlanAppController extends BaseController { ...@@ -63,12 +78,12 @@ public class RiskPlanAppController extends BaseController {
* 获取项目下的楼宇 * 获取项目下的楼宇
* *
* @param projectId 项目id * @param projectId 项目id
* @param type 类型 地上、地下 * @param type 类型 地上、地下
* @real_return {@link R<List<LedgerBuilding>>} * @real_return {@link R<List<LedgerBuilding>>}
*/ */
@GetMapping("/building/list/{projectId}") @GetMapping("/building/list/{projectId}")
public R<List<LedgerBuilding>> getBuildingListByProjectId(@PathVariable("projectId") Long projectId,String type){ public R<List<LedgerBuilding>> getBuildingListByProjectId(@PathVariable("projectId") Long projectId, String type) {
return R.ok(ledgerBuildingService.getBuildingListByProjectId(projectId,type)); return R.ok(ledgerBuildingService.getBuildingListByProjectId(projectId, type));
} }
/** /**
...@@ -78,7 +93,7 @@ public class RiskPlanAppController extends BaseController { ...@@ -78,7 +93,7 @@ public class RiskPlanAppController extends BaseController {
* @real_return {@link R<List<SysUser>>} * @real_return {@link R<List<SysUser>>}
*/ */
@GetMapping("/user/list/{projectId}") @GetMapping("/user/list/{projectId}")
public R<List<SysUser>> getUserListByProjectId(@PathVariable("projectId") Long projectId){ public R<List<SysUser>> getUserListByProjectId(@PathVariable("projectId") Long projectId) {
return R.ok(ledgerProjectService.getUserListByProjectId(projectId)); return R.ok(ledgerProjectService.getUserListByProjectId(projectId));
} }
...@@ -89,7 +104,7 @@ public class RiskPlanAppController extends BaseController { ...@@ -89,7 +104,7 @@ public class RiskPlanAppController extends BaseController {
* @real_return {@link R<List<LedgerProject>>} * @real_return {@link R<List<LedgerProject>>}
*/ */
@PostMapping() @PostMapping()
public R<Integer> saveRiskPlan(@RequestBody RiskPlan riskPlan){ public R<Integer> saveRiskPlan(@RequestBody RiskPlan riskPlan) {
riskPlan.setCreateUserId(getUserId()); riskPlan.setCreateUserId(getUserId());
riskPlan.setCreateDeptId(getDeptId()); riskPlan.setCreateDeptId(getDeptId());
return R.ok(riskPlanService.saveRiskPlan(riskPlan)); return R.ok(riskPlanService.saveRiskPlan(riskPlan));
...@@ -102,15 +117,15 @@ public class RiskPlanAppController extends BaseController { ...@@ -102,15 +117,15 @@ public class RiskPlanAppController extends BaseController {
* @real_return {@link R<List<RiskPlanAppListDto>>} * @real_return {@link R<List<RiskPlanAppListDto>>}
*/ */
@GetMapping("/create/list") @GetMapping("/create/list")
public R<List<RiskPlanAppListDto>> getRiskPlanAppListDtoListByCreateUser(String status){ public R<List<RiskPlanAppListDto>> getRiskPlanAppListDtoListByCreateUser(String status) {
List<RiskPlanStatusType> statusList; List<RiskPlanStatusType> statusList;
if ("running".equals(status)){ if ("running".equals(status)) {
statusList = Arrays.asList(RiskPlanStatusType.WAIT_START,RiskPlanStatusType.RUNNING); statusList = Arrays.asList(RiskPlanStatusType.WAIT_START, RiskPlanStatusType.RUNNING);
}else { } else {
statusList = Arrays.asList(RiskPlanStatusType.WAIT_FINISH,RiskPlanStatusType.FINISH statusList = Arrays.asList(RiskPlanStatusType.WAIT_FINISH, RiskPlanStatusType.FINISH
,RiskPlanStatusType.WAIT_ADJUST,RiskPlanStatusType.REVOKE); , RiskPlanStatusType.WAIT_ADJUST, RiskPlanStatusType.REVOKE);
} }
return R.ok(riskPlanService.getRiskPlanAppListDtoList(statusList,getUserId(),null)); return R.ok(riskPlanService.getRiskPlanAppListDtoList(statusList, getUserId(), null));
} }
/** /**
...@@ -119,8 +134,8 @@ public class RiskPlanAppController extends BaseController { ...@@ -119,8 +134,8 @@ public class RiskPlanAppController extends BaseController {
* @real_return {@link R<List<RiskPlanAppListDto>>} * @real_return {@link R<List<RiskPlanAppListDto>>}
*/ */
@GetMapping("/task/list") @GetMapping("/task/list")
public R<List<RiskPlanAppListDto>> getRiskPlanAppListDtoListByLeaderUser(){ public R<List<RiskPlanAppListDto>> getRiskPlanAppListDtoListByLeaderUser() {
return R.ok(riskPlanService.getRiskPlanAppListDtoList(null,null,getUserId())); return R.ok(riskPlanService.getRiskPlanAppListDtoList(null, null, getUserId()));
} }
/** /**
...@@ -130,7 +145,7 @@ public class RiskPlanAppController extends BaseController { ...@@ -130,7 +145,7 @@ public class RiskPlanAppController extends BaseController {
* @real_return {@link R<RiskPlanAppDetailsDto>} * @real_return {@link R<RiskPlanAppDetailsDto>}
*/ */
@GetMapping("/details/{planId}") @GetMapping("/details/{planId}")
public R<RiskPlanAppDetailsDto> getRiskPlanAppDetailsDtoByPlanId(@PathVariable("planId") Long planId){ public R<RiskPlanAppDetailsDto> getRiskPlanAppDetailsDtoByPlanId(@PathVariable("planId") Long planId) {
return R.ok(riskPlanService.getRiskPlanAppDetailsDtoByPlanId(planId)); return R.ok(riskPlanService.getRiskPlanAppDetailsDtoByPlanId(planId));
} }
...@@ -141,7 +156,7 @@ public class RiskPlanAppController extends BaseController { ...@@ -141,7 +156,7 @@ public class RiskPlanAppController extends BaseController {
* @real_return {@link R<List<LedgerBuilding>>} * @real_return {@link R<List<LedgerBuilding>>}
*/ */
@GetMapping("/plan/building/list/{planId}") @GetMapping("/plan/building/list/{planId}")
public R<List<LedgerBuilding>> getBuildingListByPlanId(@PathVariable("planId") Long planId){ public R<List<LedgerBuilding>> getBuildingListByPlanId(@PathVariable("planId") Long planId) {
return R.ok(riskPlanService.getBuildingListByPlanId(planId)); return R.ok(riskPlanService.getBuildingListByPlanId(planId));
} }
...@@ -152,7 +167,7 @@ public class RiskPlanAppController extends BaseController { ...@@ -152,7 +167,7 @@ public class RiskPlanAppController extends BaseController {
* @real_return {@link R<List<LedgerFloor>>} * @real_return {@link R<List<LedgerFloor>>}
*/ */
@GetMapping("/floor/list/{buildingId}") @GetMapping("/floor/list/{buildingId}")
public R<List<LedgerFloor>> getFloorListByBuildingId(@PathVariable("buildingId") Long buildingId){ public R<List<LedgerFloor>> getFloorListByBuildingId(@PathVariable("buildingId") Long buildingId) {
return R.ok(ledgerFloorService.getFloorListByBuildingId(buildingId)); return R.ok(ledgerFloorService.getFloorListByBuildingId(buildingId));
} }
...@@ -163,22 +178,76 @@ public class RiskPlanAppController extends BaseController { ...@@ -163,22 +178,76 @@ public class RiskPlanAppController extends BaseController {
* @real_return {@link R<List<LedgerRoom>>} * @real_return {@link R<List<LedgerRoom>>}
*/ */
@GetMapping("/room/list/{floorId}") @GetMapping("/room/list/{floorId}")
public R<List<LedgerRoom>> getRoomListByBuildingId(@PathVariable("floorId") Long floorId){ public R<List<LedgerRoom>> getRoomListByBuildingId(@PathVariable("floorId") Long floorId) {
return R.ok(ledgerRoomService.getRoomListByBuildingId(floorId)); return R.ok(ledgerRoomService.getRoomListByBuildingId(floorId));
} }
/** /**
* 根据计划id、楼宇id、楼层id、房间id获取房间列表 * 根据计划id、楼宇id、楼层id、房间id获取固有风险列表
* *
* @param planId 计划id * @param planId 计划id
* @param buildingId 楼宇id * @param buildingId 楼宇id
* @param floorId 楼层id * @param floorId 楼层id
* @param roomId 房间id * @param roomId 房间id
* @real_return {@link R<List<LedgerRoom>>} * @real_return {@link R<List<LedgerRoom>>}
*/ */
@GetMapping("/inherent/list/{planId}/{buildingId}") @GetMapping("/inherent/list/{planId}/{buildingId}")
public R<List<RiskPlanAppInherentListDto>> getInherentListByPlanId(@PathVariable("planId") Long planId public R<List<RiskPlanAppInherentListDto>> getInherentListByPlanId(@PathVariable("planId") Long planId
,@PathVariable("buildingId") Long buildingId,Long floorId,Long roomId){ , @PathVariable("buildingId") Long buildingId, Long floorId, Long roomId) {
return R.ok(riskPlanInherentListService.getInherentListByPlanId(planId,buildingId, floorId, roomId)); return R.ok(riskPlanInherentListService.getInherentListByPlanId(planId, buildingId, floorId, roomId));
}
/**
* 添加固有风险
*
* @param saveDto 固有风险表单
* @real_return {@link R<Integer>}
*/
@PostMapping("/inherent")
public R<Integer> saveRiskInherentListSaveDto(RiskInherentListSaveDto saveDto
, @RequestParam(value = "pictureFile[]", required = false) MultipartFile[] pictureFile
, @RequestParam(value = "measuresProjectFile[]", required = false) MultipartFile[] measuresProjectFile
, @RequestParam(value = "measuresAdministrationFile[]", required = false) MultipartFile[] measuresAdministrationFile
, @RequestParam(value = "measuresEmergencyFile[]", required = false) MultipartFile[] measuresEmergencyFile) {
String userId = getUserId().toString();
//风险源照片
if (pictureFile != null) {
String pictureFileIds = Arrays.stream(pictureFile)
.filter(multipartFile -> !multipartFile.isEmpty())
.map(multipartFile -> uploadFileService.upload(multipartFile, RuoYiConfig.getUploadPath(), userId, serverAddress).toString())
.collect(Collectors.joining(","));
saveDto.setPictureFileIds(pictureFileIds);
}
//工程技术措施附件
if (measuresProjectFile != null) {
String measuresProjectFileIds = Arrays.stream(measuresProjectFile)
.filter(multipartFile -> !multipartFile.isEmpty())
.map(multipartFile -> uploadFileService.upload(multipartFile, RuoYiConfig.getUploadPath(), userId, serverAddress).toString())
.collect(Collectors.joining(","));
saveDto.setMeasuresProjectFileIds(measuresProjectFileIds);
}
//管理措施附件
if (measuresAdministrationFile != null) {
String measuresAdministrationFileIds = Arrays.stream(measuresAdministrationFile)
.filter(multipartFile -> !multipartFile.isEmpty())
.map(multipartFile -> uploadFileService.upload(multipartFile, RuoYiConfig.getUploadPath(), userId, serverAddress).toString())
.collect(Collectors.joining(","));
saveDto.setMeasuresAdministrationFileIds(measuresAdministrationFileIds);
}
//应急处置措施附件
if (measuresEmergencyFile != null) {
String measuresEmergencyFileIds = Arrays.stream(measuresEmergencyFile)
.filter(multipartFile -> !multipartFile.isEmpty())
.map(multipartFile -> uploadFileService.upload(multipartFile, RuoYiConfig.getUploadPath(), userId, serverAddress).toString())
.collect(Collectors.joining(","));
saveDto.setMeasuresEmergencyFileIds(measuresEmergencyFileIds);
}
return R.ok(riskPlanInherentListService.saveRiskInherentListSaveDto(saveDto));
} }
} }
package com.censoft.censoftrongtong.domain.dto;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 固有风险清单库对象 risk_inherent_list
*
* @author ruoyi
* @date 2023-06-26
*/
@Data
public class RiskInherentListSaveDto{
/** id */
private Long id;
/** 评估人id */
private Long userId;
/** 房间id */
private Long roomId;
/** 计划id */
private Long planId;
/** 风险源名称 */
private String name;
/** 风险因素 */
private String factor;
/** 事故类型 */
private String type;
/** 风险等级 */
private String level;
/** 存在部位 */
private String presenceLocation;
/** 风险源照片id */
private String pictureFileIds;
/** 工程技术措施 */
private String measuresProject;
/** 工程技术措施附件 */
private String measuresProjectFileIds;
/** 管理措施 */
private String measuresAdministration;
/** 管理措施附件 */
private String measuresAdministrationFileIds;
/** 应急处置措施 */
private String measuresEmergency;
/** 应急处置措施附件 */
private String measuresEmergencyFileIds;
/** 参考依据 */
private String referenceBasis;
}
package com.censoft.censoftrongtong.service; package com.censoft.censoftrongtong.service;
import com.censoft.censoftrongtong.domain.RiskPlanInherentList; import com.censoft.censoftrongtong.domain.RiskPlanInherentList;
import com.censoft.censoftrongtong.domain.dto.RiskInherentListSaveDto;
import com.censoft.censoftrongtong.domain.dto.RiskPlanAppInherentListDto; import com.censoft.censoftrongtong.domain.dto.RiskPlanAppInherentListDto;
import java.util.List; import java.util.List;
...@@ -62,4 +63,6 @@ public interface IRiskPlanInherentListService ...@@ -62,4 +63,6 @@ public interface IRiskPlanInherentListService
public int deleteRiskPlanInherentListById(Long id); public int deleteRiskPlanInherentListById(Long id);
List<RiskPlanAppInherentListDto> getInherentListByPlanId(Long planId, Long buildingId, Long floorId, Long roomId); List<RiskPlanAppInherentListDto> getInherentListByPlanId(Long planId, Long buildingId, Long floorId, Long roomId);
Integer saveRiskInherentListSaveDto(RiskInherentListSaveDto saveDto);
} }
...@@ -3,10 +3,12 @@ package com.censoft.censoftrongtong.service.impl; ...@@ -3,10 +3,12 @@ package com.censoft.censoftrongtong.service.impl;
import java.util.List; import java.util.List;
import com.censoft.censoftrongtong.domain.RiskPlanInherentList; import com.censoft.censoftrongtong.domain.RiskPlanInherentList;
import com.censoft.censoftrongtong.domain.dto.RiskInherentListSaveDto;
import com.censoft.censoftrongtong.domain.dto.RiskPlanAppInherentListDto; import com.censoft.censoftrongtong.domain.dto.RiskPlanAppInherentListDto;
import com.censoft.censoftrongtong.mapper.RiskPlanInherentListMapper; import com.censoft.censoftrongtong.mapper.RiskPlanInherentListMapper;
import com.censoft.censoftrongtong.service.IRiskPlanInherentListService; import com.censoft.censoftrongtong.service.IRiskPlanInherentListService;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -100,4 +102,11 @@ public class RiskPlanInherentListServiceImpl implements IRiskPlanInherentListSer ...@@ -100,4 +102,11 @@ public class RiskPlanInherentListServiceImpl implements IRiskPlanInherentListSer
public List<RiskPlanAppInherentListDto> getInherentListByPlanId(Long planId, Long buildingId, Long floorId, Long roomId) { public List<RiskPlanAppInherentListDto> getInherentListByPlanId(Long planId, Long buildingId, Long floorId, Long roomId) {
return riskPlanInherentListMapper.getInherentListByPlanId(planId, buildingId, floorId, roomId); return riskPlanInherentListMapper.getInherentListByPlanId(planId, buildingId, floorId, roomId);
} }
@Override
public Integer saveRiskInherentListSaveDto(RiskInherentListSaveDto saveDto) {
RiskPlanInherentList inherentList = new RiskPlanInherentList();
BeanUtils.copyProperties(saveDto,inherentList);
return insertRiskPlanInherentList(inherentList);
}
} }
...@@ -14,6 +14,8 @@ ruoyi: ...@@ -14,6 +14,8 @@ ruoyi:
addressEnabled: false addressEnabled: false
# 验证码类型 math 数字计算 char 字符验证 # 验证码类型 math 数字计算 char 字符验证
captchaType: math captchaType: math
# 服务器地址
serverAddress: http://192.168.4.232/dev-api
# 开发环境配置 # 开发环境配置
server: server:
......
package com.ruoyi.framework.config;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;
import javax.servlet.MultipartConfigElement;
/**
* @author 周昊
* @desc ...
* @date 2023-06-28 14:54:58
*/
@Configuration
public class FileUploadConfig {
@Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
factory.setMaxFileSize(DataSize.ofMegabytes(10)); // 设置最大文件大小为10MB
factory.setMaxRequestSize(DataSize.ofMegabytes(20)); // 设置最大请求大小为10MB
return factory.createMultipartConfig();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment