From a351ed15666d762d8f75bf35ec74c381a6120874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E5=9B=BD=E4=B8=9C?= Date: Tue, 20 Sep 2022 17:46:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=81=E4=B8=9A=E7=AB=AF=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rzyc/controller/PcCompanyController.java | 107 ++++++++++++ .../com/rzyc/controller/RiskController.java | 161 ++++++++++++++++++ .../src/main/resources/application-dev.yml | 3 - .../src/main/resources/application-prod.yml | 2 - .../src/main/resources/application-test.yml | 0 5 files changed, 268 insertions(+), 5 deletions(-) create mode 100644 inventory-ent/src/main/java/com/rzyc/controller/PcCompanyController.java create mode 100644 inventory-ent/src/main/java/com/rzyc/controller/RiskController.java create mode 100644 inventory-gov/src/main/resources/application-test.yml diff --git a/inventory-ent/src/main/java/com/rzyc/controller/PcCompanyController.java b/inventory-ent/src/main/java/com/rzyc/controller/PcCompanyController.java new file mode 100644 index 0000000..b3f9ff4 --- /dev/null +++ b/inventory-ent/src/main/java/com/rzyc/controller/PcCompanyController.java @@ -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 companyDetail(String SysEnterpriseId)throws Exception { + SingleResult singleResult = new SingleResult(); + List sysEnterprises = sysEnterpriseMapper.companyDetail(SysEnterpriseId); + ListsafeClass = new ArrayList<>(); + if (StringUtils.isNotBlank(sysEnterprises.get(0).getBasesafeclassid())){ + safeClass = super.exchange(sysEnterprises.get(0).getBasesafeclassid(),1); + } + ListincClass = new ArrayList<>(); + if(StringUtils.isNotBlank(sysEnterprises.get(0).getBaseinclassid())){ + incClass = super.exchange(sysEnterprises.get(0).getBaseinclassid(),2); + } + ListworkClass = 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 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; + } + +} diff --git a/inventory-ent/src/main/java/com/rzyc/controller/RiskController.java b/inventory-ent/src/main/java/com/rzyc/controller/RiskController.java new file mode 100644 index 0000000..9199dc2 --- /dev/null +++ b/inventory-ent/src/main/java/com/rzyc/controller/RiskController.java @@ -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 sourcesAdd(@Valid SourcesAddDto sourcesAddDto) throws Exception { + SingleResult 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 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 sourcesDel(@Valid SourcesDelDto sourcesDelDto) throws Exception { + SingleResult 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; + } +} diff --git a/inventory-gov/src/main/resources/application-dev.yml b/inventory-gov/src/main/resources/application-dev.yml index c95ed8c..7254470 100644 --- a/inventory-gov/src/main/resources/application-dev.yml +++ b/inventory-gov/src/main/resources/application-dev.yml @@ -88,9 +88,6 @@ onstants: zip_path: /mnt/rzyc/resource/inventory/zip #导出word模板路径 word_tmp: /mnt/rzyc/resource/inventory/wordtmp - #工作要务任务类型id - work_priorities:6e631a1a-b6d1-11eb-9d3c-00163e0c1c63 - #加密 diff --git a/inventory-gov/src/main/resources/application-prod.yml b/inventory-gov/src/main/resources/application-prod.yml index 5a29376..7254470 100644 --- a/inventory-gov/src/main/resources/application-prod.yml +++ b/inventory-gov/src/main/resources/application-prod.yml @@ -88,8 +88,6 @@ onstants: zip_path: /mnt/rzyc/resource/inventory/zip #导出word模板路径 word_tmp: /mnt/rzyc/resource/inventory/wordtmp - #工作要务任务类型id - work_priorities:6e631a1a-b6d1-11eb-9d3c-00163e0c1c63 #加密 diff --git a/inventory-gov/src/main/resources/application-test.yml b/inventory-gov/src/main/resources/application-test.yml new file mode 100644 index 0000000..e69de29