Commit edf09961 authored by 周昊's avatar 周昊

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

parent 6ca61ccc
package com.censoft.censoftrongtong.controller;
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.RiskPlanAppInherentListDto;
import com.censoft.censoftrongtong.domain.dto.RiskPlanAppListDto;
import com.censoft.censoftrongtong.enums.RiskPlanStatusType;
import com.censoft.censoftrongtong.service.*;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R;
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.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
......@@ -46,6 +52,15 @@ public class RiskPlanAppController extends BaseController {
@Resource
private IRiskPlanInherentListService riskPlanInherentListService;
@Resource
private ISysUploadFileService uploadFileService;
/**
* 服务器地址
*/
@Value("${ruoyi.serverAddress}")
private String serverAddress;
/**
* 获取自身部门及以下的项目
*
......@@ -53,7 +68,7 @@ public class RiskPlanAppController extends BaseController {
* @real_return {@link R<List<LedgerProject>>}
*/
@GetMapping("/project/list")
public R<List<LedgerProject>> getProjectList(LedgerProject ledgerProject){
public R<List<LedgerProject>> getProjectList(LedgerProject ledgerProject) {
//添加自身及以下部门筛选
ledgerProject.setDeptId(getLoginUser().getDeptId());
return R.ok(ledgerProjectService.getProjectListByDeptId(ledgerProject));
......@@ -67,8 +82,8 @@ public class RiskPlanAppController extends BaseController {
* @real_return {@link R<List<LedgerBuilding>>}
*/
@GetMapping("/building/list/{projectId}")
public R<List<LedgerBuilding>> getBuildingListByProjectId(@PathVariable("projectId") Long projectId,String type){
return R.ok(ledgerBuildingService.getBuildingListByProjectId(projectId,type));
public R<List<LedgerBuilding>> getBuildingListByProjectId(@PathVariable("projectId") Long projectId, String type) {
return R.ok(ledgerBuildingService.getBuildingListByProjectId(projectId, type));
}
/**
......@@ -78,7 +93,7 @@ public class RiskPlanAppController extends BaseController {
* @real_return {@link R<List<SysUser>>}
*/
@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));
}
......@@ -89,7 +104,7 @@ public class RiskPlanAppController extends BaseController {
* @real_return {@link R<List<LedgerProject>>}
*/
@PostMapping()
public R<Integer> saveRiskPlan(@RequestBody RiskPlan riskPlan){
public R<Integer> saveRiskPlan(@RequestBody RiskPlan riskPlan) {
riskPlan.setCreateUserId(getUserId());
riskPlan.setCreateDeptId(getDeptId());
return R.ok(riskPlanService.saveRiskPlan(riskPlan));
......@@ -102,15 +117,15 @@ public class RiskPlanAppController extends BaseController {
* @real_return {@link R<List<RiskPlanAppListDto>>}
*/
@GetMapping("/create/list")
public R<List<RiskPlanAppListDto>> getRiskPlanAppListDtoListByCreateUser(String status){
public R<List<RiskPlanAppListDto>> getRiskPlanAppListDtoListByCreateUser(String status) {
List<RiskPlanStatusType> statusList;
if ("running".equals(status)){
statusList = Arrays.asList(RiskPlanStatusType.WAIT_START,RiskPlanStatusType.RUNNING);
}else {
statusList = Arrays.asList(RiskPlanStatusType.WAIT_FINISH,RiskPlanStatusType.FINISH
,RiskPlanStatusType.WAIT_ADJUST,RiskPlanStatusType.REVOKE);
if ("running".equals(status)) {
statusList = Arrays.asList(RiskPlanStatusType.WAIT_START, RiskPlanStatusType.RUNNING);
} else {
statusList = Arrays.asList(RiskPlanStatusType.WAIT_FINISH, RiskPlanStatusType.FINISH
, 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 {
* @real_return {@link R<List<RiskPlanAppListDto>>}
*/
@GetMapping("/task/list")
public R<List<RiskPlanAppListDto>> getRiskPlanAppListDtoListByLeaderUser(){
return R.ok(riskPlanService.getRiskPlanAppListDtoList(null,null,getUserId()));
public R<List<RiskPlanAppListDto>> getRiskPlanAppListDtoListByLeaderUser() {
return R.ok(riskPlanService.getRiskPlanAppListDtoList(null, null, getUserId()));
}
/**
......@@ -130,7 +145,7 @@ public class RiskPlanAppController extends BaseController {
* @real_return {@link R<RiskPlanAppDetailsDto>}
*/
@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));
}
......@@ -141,7 +156,7 @@ public class RiskPlanAppController extends BaseController {
* @real_return {@link R<List<LedgerBuilding>>}
*/
@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));
}
......@@ -152,7 +167,7 @@ public class RiskPlanAppController extends BaseController {
* @real_return {@link R<List<LedgerFloor>>}
*/
@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));
}
......@@ -163,12 +178,12 @@ public class RiskPlanAppController extends BaseController {
* @real_return {@link R<List<LedgerRoom>>}
*/
@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));
}
/**
* 根据计划id、楼宇id、楼层id、房间id获取房间列表
* 根据计划id、楼宇id、楼层id、房间id获取固有风险列表
*
* @param planId 计划id
* @param buildingId 楼宇id
......@@ -178,7 +193,61 @@ public class RiskPlanAppController extends BaseController {
*/
@GetMapping("/inherent/list/{planId}/{buildingId}")
public R<List<RiskPlanAppInherentListDto>> getInherentListByPlanId(@PathVariable("planId") Long planId
,@PathVariable("buildingId") Long buildingId,Long floorId,Long roomId){
return R.ok(riskPlanInherentListService.getInherentListByPlanId(planId,buildingId, floorId, roomId));
, @PathVariable("buildingId") Long buildingId, Long floorId, Long 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;
import com.censoft.censoftrongtong.domain.RiskPlanInherentList;
import com.censoft.censoftrongtong.domain.dto.RiskInherentListSaveDto;
import com.censoft.censoftrongtong.domain.dto.RiskPlanAppInherentListDto;
import java.util.List;
......@@ -62,4 +63,6 @@ public interface IRiskPlanInherentListService
public int deleteRiskPlanInherentListById(Long id);
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;
import java.util.List;
import com.censoft.censoftrongtong.domain.RiskPlanInherentList;
import com.censoft.censoftrongtong.domain.dto.RiskInherentListSaveDto;
import com.censoft.censoftrongtong.domain.dto.RiskPlanAppInherentListDto;
import com.censoft.censoftrongtong.mapper.RiskPlanInherentListMapper;
import com.censoft.censoftrongtong.service.IRiskPlanInherentListService;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -100,4 +102,11 @@ public class RiskPlanInherentListServiceImpl implements IRiskPlanInherentListSer
public List<RiskPlanAppInherentListDto> getInherentListByPlanId(Long planId, Long buildingId, Long floorId, Long 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:
addressEnabled: false
# 验证码类型 math 数字计算 char 字符验证
captchaType: math
# 服务器地址
serverAddress: http://192.168.4.232/dev-api
# 开发环境配置
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