2022-09-20 17:46:56 +08:00
|
|
|
package com.rzyc.controller;
|
|
|
|
|
|
|
|
|
|
import com.common.utils.StringUtils;
|
2022-09-28 15:42:17 +08:00
|
|
|
import com.common.utils.TypeConversion;
|
|
|
|
|
import com.common.utils.model.*;
|
|
|
|
|
import com.github.pagehelper.Page;
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
import com.rzyc.advice.LoginAuth;
|
|
|
|
|
import com.rzyc.bean.risk.*;
|
2022-09-20 17:46:56 +08:00
|
|
|
import com.rzyc.enums.DelState;
|
|
|
|
|
import com.rzyc.enums.ResourceRiskLevel;
|
2022-09-28 15:42:17 +08:00
|
|
|
import com.rzyc.model.RkRiskType;
|
2022-09-20 17:46:56 +08:00
|
|
|
import com.rzyc.model.RkSources;
|
|
|
|
|
import com.rzyc.model.ent.SysEnterprise;
|
|
|
|
|
import io.swagger.annotations.Api;
|
2022-09-28 15:42:17 +08:00
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
2022-09-20 17:46:56 +08:00
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.apache.commons.beanutils.BeanUtils;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
2022-09-28 15:42:17 +08:00
|
|
|
import org.springframework.web.bind.annotation.*;
|
2022-09-20 17:46:56 +08:00
|
|
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
2022-09-28 15:42:17 +08:00
|
|
|
import java.util.List;
|
2022-09-20 17:46:56 +08:00
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author dong
|
|
|
|
|
* @date 2022-09-20 17:40
|
|
|
|
|
* @Version V1.0
|
|
|
|
|
*/
|
|
|
|
|
@Api(tags = "重大危险源")
|
|
|
|
|
@CrossOrigin("*")
|
|
|
|
|
@RequestMapping("risk")
|
|
|
|
|
@RestController
|
|
|
|
|
@Validated
|
|
|
|
|
public class RiskController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 企业重大危险源新增修改
|
|
|
|
|
*
|
|
|
|
|
* @version v1.0
|
|
|
|
|
* @author dong
|
|
|
|
|
* @date 2022/8/2 9:34
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation(value = "重大危险源新增修改", notes = "企业重大危险源新增修改")
|
|
|
|
|
@PostMapping("/sourcesAdd")
|
|
|
|
|
public SingleResult<String> sourcesAdd(@Valid SourcesAddDto sourcesAddDto) throws Exception {
|
|
|
|
|
SingleResult<String> result = new SingleResult<>();
|
|
|
|
|
|
|
|
|
|
String userId = getUserId();
|
|
|
|
|
RkSources sources = new RkSources();
|
|
|
|
|
BeanUtils.copyProperties(sources, sourcesAddDto);
|
|
|
|
|
|
|
|
|
|
sources.setModified(userId);
|
|
|
|
|
sources.setModifyTime(new Date());
|
|
|
|
|
|
|
|
|
|
SysEnterprise enterprise = sysEnterpriseMapper.selectByPrimaryKey(sourcesAddDto.getEnterpriseId());
|
|
|
|
|
if (null != enterprise) {
|
|
|
|
|
sources.setEntName(enterprise.getEntname());
|
|
|
|
|
sources.setOrgcode(enterprise.getOrgcode());
|
|
|
|
|
sources.setStreetCode(enterprise.getStreetCode());
|
|
|
|
|
sources.setCommunityCode(enterprise.getCommunityCode());
|
|
|
|
|
//最新工作单元行业id
|
|
|
|
|
sources.setBaseInclassId(enterprise.getWorkClassId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//计算风险等级
|
|
|
|
|
Integer riskGrade = getRiskLevel(sources.getPossibility(), sources.getSeriousness());
|
|
|
|
|
sources.setRiskGrade(riskGrade);
|
|
|
|
|
|
|
|
|
|
RkSources rkSources = rkSourcesMapper.selectById(sources.getSourceId());
|
|
|
|
|
if (null != rkSources) {
|
|
|
|
|
rkSourcesMapper.updateById(sources);
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
sources.setXindex("");
|
|
|
|
|
sources.setYindex("");
|
|
|
|
|
sources.setDelState(DelState.NOT_DEL.getState());
|
|
|
|
|
|
|
|
|
|
sources.setCreated(userId);
|
|
|
|
|
sources.setCreateTime(new Date());
|
|
|
|
|
rkSourcesMapper.insert(sources);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param possibility 可能性
|
|
|
|
|
* @param seriousness 后果严重性
|
|
|
|
|
* @return
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public Integer getRiskLevel(Integer possibility, Integer seriousness) throws Exception {
|
|
|
|
|
Integer riskLevel = ResourceRiskLevel.BLUE.getLevel();
|
|
|
|
|
|
|
|
|
|
//风险等级
|
|
|
|
|
Map<String, Integer> riskLevelMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
riskLevelMap.put("1-1", 1);
|
|
|
|
|
riskLevelMap.put("1-2", 1);
|
|
|
|
|
riskLevelMap.put("1-3", 1);
|
|
|
|
|
riskLevelMap.put("1-4", 2);
|
|
|
|
|
riskLevelMap.put("1-5", 3);
|
|
|
|
|
|
|
|
|
|
riskLevelMap.put("2-1", 1);
|
|
|
|
|
riskLevelMap.put("2-2", 1);
|
|
|
|
|
riskLevelMap.put("2-3", 2);
|
|
|
|
|
riskLevelMap.put("2-4", 3);
|
|
|
|
|
riskLevelMap.put("2-5", 4);
|
|
|
|
|
|
|
|
|
|
riskLevelMap.put("3-1", 1);
|
|
|
|
|
riskLevelMap.put("3-2", 1);
|
|
|
|
|
riskLevelMap.put("3-3", 2);
|
|
|
|
|
riskLevelMap.put("3-4", 3);
|
|
|
|
|
riskLevelMap.put("3-5", 4);
|
|
|
|
|
|
|
|
|
|
riskLevelMap.put("4-1", 2);
|
|
|
|
|
riskLevelMap.put("4-2", 2);
|
|
|
|
|
riskLevelMap.put("4-3", 3);
|
|
|
|
|
riskLevelMap.put("4-4", 4);
|
|
|
|
|
riskLevelMap.put("4-5", 4);
|
|
|
|
|
|
|
|
|
|
riskLevelMap.put("5-1", 2);
|
|
|
|
|
riskLevelMap.put("5-2", 3);
|
|
|
|
|
riskLevelMap.put("5-3", 4);
|
|
|
|
|
riskLevelMap.put("5-4", 4);
|
|
|
|
|
riskLevelMap.put("5-5", 4);
|
|
|
|
|
|
|
|
|
|
//风险等级
|
|
|
|
|
String key = possibility + "-" + seriousness;
|
|
|
|
|
if (null != riskLevelMap.get(key)) {
|
|
|
|
|
riskLevel = riskLevelMap.get(key);
|
|
|
|
|
}
|
|
|
|
|
return riskLevel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除危险源
|
|
|
|
|
*
|
|
|
|
|
* @version v1.0
|
|
|
|
|
* @author dong
|
|
|
|
|
* @date 2022/8/2 13:33
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation(value = "删除危险源", notes = "删除危险源")
|
|
|
|
|
@PostMapping("/sourcesDel")
|
|
|
|
|
public SingleResult<String> sourcesDel(@Valid SourcesDelDto sourcesDelDto) throws Exception {
|
|
|
|
|
SingleResult<String> result = new SingleResult<>();
|
|
|
|
|
if (StringUtils.isNotBlank(sourcesDelDto.getSourceIds())) {
|
|
|
|
|
String[] stts = sourcesDelDto.getSourceIds().split(",");
|
|
|
|
|
for (String str : stts) {
|
|
|
|
|
RkSources sources = new RkSources();
|
|
|
|
|
sources.setSourceId(str);
|
|
|
|
|
sources.setDelState(DelState.DELETE.getState());
|
|
|
|
|
rkSourcesMapper.updateById(sources);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2022-09-28 15:42:17 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 重大危险源类型
|
|
|
|
|
*
|
|
|
|
|
* @version v1.0
|
|
|
|
|
* @author dong
|
|
|
|
|
* @date 2022/8/2 9:44
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation(value = "类型 1、风险源类型 2、事故类型", notes = "类型 1、风险源类型 2、事故类型")
|
|
|
|
|
@GetMapping("/riskType/{type}")
|
|
|
|
|
@ApiImplicitParam(name = "type", value = "类型 1、风险源类型 2、事故类型", required = true)
|
|
|
|
|
public MultiResult<RkRiskType> riskType(@PathVariable Integer type) throws Exception {
|
|
|
|
|
MultiResult<RkRiskType> result = new MultiResult<>();
|
|
|
|
|
List<RkRiskType> riskTypes = rkRiskTypeMapper.findByClassId(type);
|
|
|
|
|
result.setData(riskTypes);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 企业重大危险源分页
|
|
|
|
|
*
|
|
|
|
|
* @version v1.0
|
|
|
|
|
* @author dong
|
|
|
|
|
* @date 2022/8/2 11:49
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation(value = "企业重大危险源分页", notes = "企业重大危险源分页")
|
|
|
|
|
@GetMapping("/sourcesEntPage")
|
|
|
|
|
public SingleResult<Pager<RkSources>> sourcesEntPage(@Valid SourcesPageDto sourcesPageDto) throws Exception {
|
|
|
|
|
SingleResult<Pager<RkSources>> result = new SingleResult<>();
|
|
|
|
|
String condition = TypeConversion.getCondition(sourcesPageDto.getCondition());
|
|
|
|
|
PageHelper.startPage(sourcesPageDto.getPage(), sourcesPageDto.getPageSize());
|
|
|
|
|
Page<RkSources> page = (Page<RkSources>) rkSourcesMapper.sourcesList(condition, sourcesPageDto.getEnterpriseId(), sourcesPageDto.getRiskGrade());
|
|
|
|
|
Pager<RkSources> pager = new Pager<>();
|
|
|
|
|
getDatePage(pager, page);
|
|
|
|
|
result.setData(pager);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 需要标记的危险源列表
|
|
|
|
|
*
|
|
|
|
|
* @version v1.0
|
|
|
|
|
* @author dong
|
|
|
|
|
* @date 2022/8/2 13:33
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation(value = "需要标记的危险源列表", notes = "需要标记的危险源列表")
|
|
|
|
|
@GetMapping("/sourcesNeedSign/{enterpriseId}")
|
|
|
|
|
public MultiResult<RkSources> sourcesNeedSign(@PathVariable String enterpriseId) throws Exception {
|
|
|
|
|
MultiResult<RkSources> result = new MultiResult<>();
|
|
|
|
|
List<RkSources> sources = rkSourcesMapper.findByIndex(enterpriseId);
|
|
|
|
|
result.setData(sources);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 已经标记的危险源列表
|
|
|
|
|
*
|
|
|
|
|
* @version v1.0
|
|
|
|
|
* @author dong
|
|
|
|
|
* @date 2022/8/2 13:33
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation(value = "已经标记的危险源列表", notes = "已经标记的危险源列表")
|
|
|
|
|
@GetMapping("/sourcesSigned/{enterpriseId}")
|
|
|
|
|
@ApiImplicitParams({
|
|
|
|
|
@ApiImplicitParam(name = "enterpriseId", value = "企业id"),
|
|
|
|
|
@ApiImplicitParam(name = "documentId", value = "文件id")
|
|
|
|
|
})
|
|
|
|
|
public MultiResult<RkSources> sourcesSigned(@PathVariable String enterpriseId, String documentId) throws Exception {
|
|
|
|
|
MultiResult<RkSources> result = new MultiResult<>();
|
|
|
|
|
List<RkSources> sources = rkSourcesMapper.signedSource(enterpriseId, documentId);
|
|
|
|
|
result.setData(sources);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 危险源标记
|
|
|
|
|
*
|
|
|
|
|
* @version v1.0
|
|
|
|
|
* @author dong
|
|
|
|
|
* @date 2022/8/2 13:33
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation(value = "危险源标记", notes = "危险源标记")
|
|
|
|
|
@PostMapping("/sourcesSign")
|
|
|
|
|
public SingleResult<String> sourcesSign(@Valid SourcesSignDto sourcesSignDto) throws Exception {
|
|
|
|
|
SingleResult<String> result = new SingleResult<>();
|
|
|
|
|
RkSources sources = new RkSources();
|
|
|
|
|
BeanUtils.copyProperties(sources, sourcesSignDto);
|
|
|
|
|
rkSourcesMapper.updateById(sources);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除危险源标记
|
|
|
|
|
*
|
|
|
|
|
* @version v1.0
|
|
|
|
|
* @author dong
|
|
|
|
|
* @date 2022/8/2 13:33
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation(value = "删除危险源标记", notes = "删除危险源标记")
|
|
|
|
|
@PostMapping("/sourcesSignDel/{sourceId}")
|
|
|
|
|
@ApiImplicitParam(name = "sourceId", value = "危险源id", required = true)
|
|
|
|
|
public SingleResult<String> sourcesSignDel(@PathVariable String sourceId) throws Exception {
|
|
|
|
|
SingleResult<String> result = new SingleResult<>();
|
|
|
|
|
rkSourcesMapper.changeIndex(sourceId);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 危险源详情
|
|
|
|
|
*
|
|
|
|
|
* @version v1.0
|
|
|
|
|
* @author dong
|
|
|
|
|
* @date 2022/8/2 13:33
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation(value = "危险源详情", notes = "危险源详情")
|
|
|
|
|
@PostMapping("/sourcesDetail/{sourceId}")
|
|
|
|
|
@ApiImplicitParam(name = "sourceId", value = "危险源id", required = true)
|
|
|
|
|
public SingleResult<RkSources> sourcesDetail(@PathVariable String sourceId) throws Exception {
|
|
|
|
|
SingleResult<RkSources> result = new SingleResult<>();
|
|
|
|
|
RkSources sources = rkSourcesMapper.selectById(sourceId);
|
|
|
|
|
|
|
|
|
|
if (null != sources) {
|
|
|
|
|
|
|
|
|
|
//风险源分类
|
|
|
|
|
RkRiskType riskType = rkRiskTypeMapper.selectById(sources.getSourceId());
|
|
|
|
|
if (null != riskType) {
|
|
|
|
|
sources.setSourceName(riskType.getName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//事故类型
|
|
|
|
|
RkRiskType rkRiskType = rkRiskTypeMapper.selectById(sources.getTypeId());
|
|
|
|
|
if (null != rkRiskType) {
|
|
|
|
|
sources.setTypeName(rkRiskType.getName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.setData(sources);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2022-09-20 17:46:56 +08:00
|
|
|
}
|