企业端接口调整

This commit is contained in:
韩国东 2022-09-20 17:46:56 +08:00
parent a2e43ab22b
commit a351ed1566
5 changed files with 268 additions and 5 deletions

View File

@ -0,0 +1,107 @@
package com.rzyc.controller;
import com.alibaba.fastjson.JSONArray;
import com.common.utils.StringUtils;
import com.common.utils.model.Code;
import com.common.utils.model.Message;
import com.common.utils.model.SingleResult;
import com.rzyc.model.ent.SysEnterprise;
import com.rzyc.model.user.SysUnit;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.List;
/**
* @author dong
* @date 2022-09-20 14:55
* @Version V1.0
*/
@Api(tags = "企业系统")
@CrossOrigin("*")
@RequestMapping("pcCompany")
@Controller
@Validated
public class PcCompanyController extends BaseController{
/**
* PC企业详细
* @return
*/
@ApiOperation(value = "PC企业详细", notes = "PC企业详细")
@ApiImplicitParams({
@ApiImplicitParam(name = "SysEnterpriseId", value = "公司id", required = true, dataType = "string")
})
@PostMapping("/companyDetail")
@ResponseBody
public SingleResult<String> companyDetail(String SysEnterpriseId)throws Exception {
SingleResult singleResult = new SingleResult();
List<SysEnterprise> sysEnterprises = sysEnterpriseMapper.companyDetail(SysEnterpriseId);
List<String>safeClass = new ArrayList<>();
if (StringUtils.isNotBlank(sysEnterprises.get(0).getBasesafeclassid())){
safeClass = super.exchange(sysEnterprises.get(0).getBasesafeclassid(),1);
}
List<String>incClass = new ArrayList<>();
if(StringUtils.isNotBlank(sysEnterprises.get(0).getBaseinclassid())){
incClass = super.exchange(sysEnterprises.get(0).getBaseinclassid(),2);
}
List<String>workClass = new ArrayList<>();
if(StringUtils.isNotBlank(sysEnterprises.get(0).getWorkClassId())){
incClass = super.exchange(sysEnterprises.get(0).getWorkClassId(),3);
}
sysEnterprises.get(0).setInClassName(JSONArray.toJSONString(incClass));
sysEnterprises.get(0).setSafeClassName(JSONArray.toJSONString(safeClass));
sysEnterprises.get(0).setWorkClassName(JSONArray.toJSONString(incClass));
String orgName = sysEnterprises.get(0).getOrgName();
if(StringUtils.isNotBlank(sysEnterprises.get(0).getStreetName())){
orgName = orgName + "-" + sysEnterprises.get(0).getStreetName();
}
if(StringUtils.isNotBlank(sysEnterprises.get(0).getCommunityName())){
orgName = orgName + "-" + sysEnterprises.get(0).getCommunityName();
}
sysEnterprises.get(0).setOrgName(orgName);
List<SysUnit> units = sysUnitMapper.findUnit();
String sysUnitId = sysEnterprises.get(0).getSysUnitId();
String managerDept = sysEnterprises.get(0).getManagerDept();
String [] arr=sysUnitId.split(",");
StringBuilder stringBuilder = new StringBuilder();
for (String i:arr) {
for (SysUnit un:units) {
if (un.getSysunitid().equals(managerDept)){
sysEnterprises.get(0).setManagerDeptName(un.getUnitname());
}
if (un.getSysunitid().equals(i)){
stringBuilder.append(un.getUnitname()+",");
}
}
}
if (StringUtils.isNotBlank(stringBuilder.toString())){
sysEnterprises.get(0).setSysUnitName(stringBuilder.toString().substring(0,stringBuilder.toString().length()-1));
}
if (sysEnterprises != null){
singleResult.setMessage(Message.SUCCESS);
singleResult.setData(sysEnterprises);
singleResult.setCode(Code.SUCCESS.getCode());
}else {
singleResult.setMessage(Message.ERROR);
singleResult.setCode(Code.ERROR.getCode());
}
return singleResult;
}
}

View File

@ -0,0 +1,161 @@
package com.rzyc.controller;
import com.common.utils.StringUtils;
import com.common.utils.model.SingleResult;
import com.rzyc.bean.risk.SourcesAddDto;
import com.rzyc.bean.risk.SourcesDelDto;
import com.rzyc.enums.DelState;
import com.rzyc.enums.ResourceRiskLevel;
import com.rzyc.model.RkSources;
import com.rzyc.model.ent.SysEnterprise;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.Date;
import java.util.HashMap;
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;
}
}

View File

@ -88,9 +88,6 @@ onstants:
zip_path: /mnt/rzyc/resource/inventory/zip zip_path: /mnt/rzyc/resource/inventory/zip
#导出word模板路径 #导出word模板路径
word_tmp: /mnt/rzyc/resource/inventory/wordtmp word_tmp: /mnt/rzyc/resource/inventory/wordtmp
#工作要务任务类型id
work_priorities6e631a1a-b6d1-11eb-9d3c-00163e0c1c63
#加密 #加密

View File

@ -88,8 +88,6 @@ onstants:
zip_path: /mnt/rzyc/resource/inventory/zip zip_path: /mnt/rzyc/resource/inventory/zip
#导出word模板路径 #导出word模板路径
word_tmp: /mnt/rzyc/resource/inventory/wordtmp word_tmp: /mnt/rzyc/resource/inventory/wordtmp
#工作要务任务类型id
work_priorities6e631a1a-b6d1-11eb-9d3c-00163e0c1c63
#加密 #加密