diff --git a/src/main/java/com/zhgd/xmgl/modules/risk/controller/RiskListPointController.java b/src/main/java/com/zhgd/xmgl/modules/risk/controller/RiskListPointController.java index a3a344a52..34d457c36 100644 --- a/src/main/java/com/zhgd/xmgl/modules/risk/controller/RiskListPointController.java +++ b/src/main/java/com/zhgd/xmgl/modules/risk/controller/RiskListPointController.java @@ -5,10 +5,10 @@ import cn.afterturn.easypoi.excel.entity.TemplateExportParams; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson2.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.gexin.fastjson.serializer.SerializerFeature; import com.zhgd.annotation.OperLog; import com.zhgd.file.FileUtil; import com.zhgd.jeecg.common.api.vo.Result; @@ -93,8 +93,8 @@ public class RiskListPointController { @ApiImplicitParam(name = "pageNo", value = "第几页", paramType = "query", required = true, dataType = "Integer"), @ApiImplicitParam(name = "pageSize", value = "每页显示条数", paramType = "query", required = true, dataType = "Integer"), @ApiImplicitParam(name = "projectType", value = "工程类别(字典值)", paramType = "query", required = false, dataType = "Integer"), - @ApiImplicitParam(name = "containLibraryId", value = "查询下级的风险清单库id", paramType = "query", required = false, dataType = "Integer"), - @ApiImplicitParam(name = "regionId", value = "区域id", paramType = "query", required = false, dataType = "Integer"), + @ApiImplicitParam(name = "containLibraryIds", value = "查询下级的风险清单库id(多个,分割)", paramType = "query", required = false, dataType = "Integer"), + @ApiImplicitParam(name = "regionIds", value = "区域ids(多个,分割)", paramType = "query", required = false, dataType = "Integer"), }) @GetMapping(value = "/page") public Result> queryPageList(@ApiIgnore @RequestParam HashMap param) { @@ -203,7 +203,7 @@ public class RiskListPointController { }) @PostMapping(value = "/batchSetField") public Result batchSetField(@RequestBody Map param) { - List> updates = com.gexin.fastjson.JSON.parseObject(JSON.toJSONString(param.get("updates")), new com.gexin.fastjson.TypeReference>>() { + List> updates = com.gexin.fastjson.JSON.parseObject(com.gexin.fastjson.JSON.toJSONString(param.get("updates"), SerializerFeature.WriteMapNullValue), new com.gexin.fastjson.TypeReference>>() { }); List fieldNames = new ArrayList<>(); Field[] fields = RiskListPoint.class.getDeclaredFields(); // getFields() 只返回公共字段(包括继承的) diff --git a/src/main/java/com/zhgd/xmgl/modules/risk/controller/RiskListSourceController.java b/src/main/java/com/zhgd/xmgl/modules/risk/controller/RiskListSourceController.java index 0bdf150ca..bb5a46bce 100644 --- a/src/main/java/com/zhgd/xmgl/modules/risk/controller/RiskListSourceController.java +++ b/src/main/java/com/zhgd/xmgl/modules/risk/controller/RiskListSourceController.java @@ -12,22 +12,20 @@ import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.ZipUtil; import cn.hutool.extra.qrcode.QrCodeUtil; import cn.hutool.extra.qrcode.QrConfig; -import com.alibaba.fastjson2.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.gexin.fastjson.serializer.SerializerFeature; import com.zhgd.annotation.OperLog; import com.zhgd.jeecg.common.api.vo.Result; import com.zhgd.jeecg.common.execption.OpenAlertException; import com.zhgd.xmgl.modules.risk.entity.RiskListDetail; +import com.zhgd.xmgl.modules.risk.entity.RiskListPoint; import com.zhgd.xmgl.modules.risk.entity.RiskListSource; import com.zhgd.xmgl.modules.risk.entity.vo.RegionV2Vo; import com.zhgd.xmgl.modules.risk.entity.vo.RiskListSourceVo; import com.zhgd.xmgl.modules.risk.entity.vo.RiskUndoneVo; -import com.zhgd.xmgl.modules.risk.service.IRegionV2Service; -import com.zhgd.xmgl.modules.risk.service.IRiskListDetailService; -import com.zhgd.xmgl.modules.risk.service.IRiskListPotentialAccidentTypeService; -import com.zhgd.xmgl.modules.risk.service.IRiskListSourceService; +import com.zhgd.xmgl.modules.risk.service.*; import com.zhgd.xmgl.util.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -80,6 +78,9 @@ public class RiskListSourceController { @Lazy @Autowired private IRiskListPotentialAccidentTypeService riskListPotentialAccidentTypeService; + @Lazy + @Autowired + private IRiskListPointService riskListPointService; /** * 分页列表查询 @@ -97,6 +98,7 @@ public class RiskListSourceController { @ApiImplicitParam(name = "monthlyId", value = "月度清单id", paramType = "query", required = false, dataType = "Integer"), @ApiImplicitParam(name = "duringTheTask", value = "1是开启任务期间", paramType = "query", required = false, dataType = "Integer"), @ApiImplicitParam(name = "workable", value = "1已落实0未落实", paramType = "query", required = false, dataType = "Integer"), + @ApiImplicitParam(name = "isInConstruction", value = "1在施", paramType = "query", required = false, dataType = "Integer"), }) @GetMapping(value = "/page") public Result> queryPageList(@ApiIgnore @RequestParam HashMap param) { @@ -205,7 +207,7 @@ public class RiskListSourceController { }) @PostMapping(value = "/batchSetField") public Result batchSetField(@RequestBody Map param) { - List> updates = com.gexin.fastjson.JSON.parseObject(JSON.toJSONString(param.get("updates")), new com.gexin.fastjson.TypeReference>>() { + List> updates = com.gexin.fastjson.JSON.parseObject(com.gexin.fastjson.JSON.toJSONString(param.get("updates"), SerializerFeature.WriteMapNullValue), new com.gexin.fastjson.TypeReference>>() { }); List fieldNames = new ArrayList<>(); Field[] fields = RiskListSource.class.getDeclaredFields(); // getFields() 只返回公共字段(包括继承的) @@ -367,17 +369,23 @@ public class RiskListSourceController { List addList = new ArrayList<>(); List details = riskListDetailService.list(new LambdaQueryWrapper() .in(RiskListDetail::getId, StrUtil.split(MapUtils.getString(param, "detailIds"), ","))); + Long pointId = MapUtils.getLong(param, "pointId"); + RiskListPoint point = riskListPointService.getById(pointId); + if (point == null) { + throw new OpenAlertException("管控清单风险点不存在"); + } for (RiskListDetail detail : details) { RiskListSource source = new RiskListSource(); BeanUtils.copyProperties(detail, source); source.setId(null); source.setDetailId(detail.getId()); - source.setPointId(MapUtils.getLong(param, "pointId")); + source.setPointId(pointId); source.setCreateTime(new Date()); source.setUpdateTime(new Date()); source.setEffectiveTimeBegin(source.getEffectiveTimeBegin()); source.setEffectiveTimeEnd(source.getEffectiveTimeEnd()); source.setIdentificationTime(new Date()); + source.setProjectSn(point.getProjectSn()); addList.add(source); } if (CollUtil.isNotEmpty(addList)) { @@ -441,12 +449,13 @@ public class RiskListSourceController { objectMap.put("no", i + 1); objectMap.put("subProjectWorkTask", sourceVo.getSubProjectWorkTask()); objectMap.put("accidentTypeName", sourceVo.getAccidentTypeName()); + objectMap.put("activityFrequency", sourceVo.getActivityFrequency()); objectMap.put("areaLocation", sourceVo.getAreaLocation()); if (StrUtil.isNotBlank(sourceVo.getSpecificResponsibilityAreaNames())) { List areas = new ArrayList<>(); List split = StrUtil.split(sourceVo.getSpecificResponsibilityAreaNames(), ","); for (int j = 0; j < split.size(); j++) { - areas.add("区域:" + (j + 1) + split.get(j)); + areas.add("区域" + (j + 1) + ":" + split.get(j)); } objectMap.put("specificResponsibilityAreaNames", StrUtil.join("\n", areas)); } diff --git a/src/main/java/com/zhgd/xmgl/modules/risk/controller/RiskListSourceDataCenterController.java b/src/main/java/com/zhgd/xmgl/modules/risk/controller/RiskListSourceDataCenterController.java new file mode 100644 index 000000000..76a10a039 --- /dev/null +++ b/src/main/java/com/zhgd/xmgl/modules/risk/controller/RiskListSourceDataCenterController.java @@ -0,0 +1,85 @@ +package com.zhgd.xmgl.modules.risk.controller; + +import com.zhgd.jeecg.common.api.vo.Result; +import com.zhgd.xmgl.base.entity.vo.SectorVo; +import com.zhgd.xmgl.modules.risk.entity.vo.CountRisksByLevelVo; +import com.zhgd.xmgl.modules.risk.service.IRegionV2Service; +import com.zhgd.xmgl.modules.risk.service.IRiskListDetailService; +import com.zhgd.xmgl.modules.risk.service.IRiskListPotentialAccidentTypeService; +import com.zhgd.xmgl.modules.risk.service.IRiskListSourceService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import springfox.documentation.annotations.ApiIgnore; + +import java.util.HashMap; +import java.util.List; + + +/** + * @Title: Controller + * @Description: 管控清单危险源数据中心 + * @author: pds + * @date: 2025-06-09 + * @version: V1.0 + */ +@RestController +@RequestMapping("/xmgl/riskListSourceDataCenter") +@Slf4j +@Api(tags = "管控清单危险源数据中心相关Api") +public class RiskListSourceDataCenterController { + @Lazy + @Autowired + private IRiskListSourceService riskListSourceService; + @Lazy + @Autowired + private IRegionV2Service regionV2Service; + @Lazy + @Autowired + private IRiskListDetailService riskListDetailService; + @Lazy + @Autowired + private IRiskListPotentialAccidentTypeService riskListPotentialAccidentTypeService; + + @ApiOperation(value = "统计风险等级数量", notes = "统计风险等级数量", httpMethod = "GET") + @ApiImplicitParams({ + @ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "query", required = true, dataType = "Integer"), + @ApiImplicitParam(name = "isInConstruction", value = "1在施", paramType = "query", required = false, dataType = "Integer"), + @ApiImplicitParam(name = "projectType", value = "工程类别(字典值)", paramType = "query", required = false, dataType = "Integer"), + }) + @GetMapping(value = "/countRisksByLevel") + public Result countRisksByLevel(@ApiIgnore @RequestParam HashMap param) { + return Result.success(riskListSourceService.countRisksByLevel(param)); + } + + @ApiOperation(value = "风险走势图(按月统计)", notes = "风险走势图(按月统计)", httpMethod = "GET") + @ApiImplicitParams({ + @ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "query", required = true, dataType = "Integer"), + @ApiImplicitParam(name = "startTime", value = "开始时间(yyyy-MM)", paramType = "body", required = true, dataType = "String"), + @ApiImplicitParam(name = "endTime", value = "结束时间(yyyy-MM)", paramType = "body", required = true, dataType = "String"), + }) + @GetMapping(value = "/getRiskTrendChart") + public Result> getRiskTrendChart(@ApiIgnore @RequestParam HashMap param) { + return Result.success(riskListSourceService.getRiskTrendChart(param)); + } + + @ApiOperation(value = "(在施)风险类型占比", notes = "(在施)风险类型占比", httpMethod = "GET") + @ApiImplicitParams({ + @ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "query", required = true, dataType = "Integer"), + @ApiImplicitParam(name = "isInConstruction", value = "1在施", paramType = "query", required = false, dataType = "Integer"), + }) + @GetMapping(value = "/countRisksByLibrary") + public Result countRisksByLibrary(@RequestParam @ApiIgnore HashMap map) { + return Result.success(riskListSourceService.countRisksByLibrary(map)); + } + +} + diff --git a/src/main/java/com/zhgd/xmgl/modules/risk/entity/vo/CountRisksByLevelVo.java b/src/main/java/com/zhgd/xmgl/modules/risk/entity/vo/CountRisksByLevelVo.java new file mode 100644 index 000000000..aab2ec2d1 --- /dev/null +++ b/src/main/java/com/zhgd/xmgl/modules/risk/entity/vo/CountRisksByLevelVo.java @@ -0,0 +1,46 @@ +package com.zhgd.xmgl.modules.risk.entity.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class CountRisksByLevelVo { + /** + * 重大风险数量 + */ + @ApiModelProperty(value = "重大风险数量") + private java.lang.Integer zdNum; + /** + * 较大风险数量 + */ + @ApiModelProperty(value = "较大风险数量") + private java.lang.Integer jdNum; + /** + * 一般风险数量 + */ + @ApiModelProperty(value = "一般风险数量") + private java.lang.Integer ybNum; + /** + * 低风险数量 + */ + @ApiModelProperty(value = "低风险数量") + private java.lang.Integer dNum; + /** + * 危险源总数 + */ + @ApiModelProperty(value = "危险源总数") + private java.lang.Integer total; + /** + * 年-月 + */ + @ApiModelProperty(value = "年-月") + private java.lang.String yearMonth; + /** + * 月度环比% + */ + @ApiModelProperty(value = "月度环比%") + private BigDecimal moMChange; + +} diff --git a/src/main/java/com/zhgd/xmgl/modules/risk/entity/vo/RiskListSourceVo.java b/src/main/java/com/zhgd/xmgl/modules/risk/entity/vo/RiskListSourceVo.java index 692a3856d..585e0ffc8 100644 --- a/src/main/java/com/zhgd/xmgl/modules/risk/entity/vo/RiskListSourceVo.java +++ b/src/main/java/com/zhgd/xmgl/modules/risk/entity/vo/RiskListSourceVo.java @@ -1,5 +1,6 @@ package com.zhgd.xmgl.modules.risk.entity.vo; +import com.baomidou.mybatisplus.annotation.TableField; import com.zhgd.xmgl.modules.risk.entity.RiskListSource; import io.swagger.annotations.ApiModelProperty; import lombok.Data; diff --git a/src/main/java/com/zhgd/xmgl/modules/risk/mapper/RiskListSourceMapper.java b/src/main/java/com/zhgd/xmgl/modules/risk/mapper/RiskListSourceMapper.java index 161954796..558a11bb6 100644 --- a/src/main/java/com/zhgd/xmgl/modules/risk/mapper/RiskListSourceMapper.java +++ b/src/main/java/com/zhgd/xmgl/modules/risk/mapper/RiskListSourceMapper.java @@ -5,7 +5,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Constants; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.zhgd.xmgl.base.entity.vo.SectorOneVo; import com.zhgd.xmgl.modules.risk.entity.RiskListSource; +import com.zhgd.xmgl.modules.risk.entity.vo.CountRisksByLevelVo; import com.zhgd.xmgl.modules.risk.entity.vo.RiskListSourceVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -49,4 +51,8 @@ public interface RiskListSourceMapper extends BaseMapper { * @return */ RiskListSourceVo queryById(String id); + + CountRisksByLevelVo countRisksByLevel(HashMap param); + + List countRisksByLibrary(HashMap map); } diff --git a/src/main/java/com/zhgd/xmgl/modules/risk/mapper/xml/RiskListPointMapper.xml b/src/main/java/com/zhgd/xmgl/modules/risk/mapper/xml/RiskListPointMapper.xml index 62f3ef28f..00bc7a98f 100644 --- a/src/main/java/com/zhgd/xmgl/modules/risk/mapper/xml/RiskListPointMapper.xml +++ b/src/main/java/com/zhgd/xmgl/modules/risk/mapper/xml/RiskListPointMapper.xml @@ -10,12 +10,18 @@ and rll.project_type = #{param.projectType} - - and rll.id in (select id from risk_list_library where find_in_set(#{param.containLibraryId},ancestors) or - id=#{param.containLibraryId}) + + and rll.id in (select id from risk_list_library where + + FIND_IN_SET(#{libraryId}, ancestors) OR id = #{libraryId} + + ) - - and find_in_set(#{param.regionId},t.specific_responsibility_area_ids) + + and + + find_in_set(#{regionId},t.specific_responsibility_area_ids) + )t ${ew.customSqlSegment} diff --git a/src/main/java/com/zhgd/xmgl/modules/risk/mapper/xml/RiskListSourceMapper.xml b/src/main/java/com/zhgd/xmgl/modules/risk/mapper/xml/RiskListSourceMapper.xml index bd4229316..1495cf5d4 100644 --- a/src/main/java/com/zhgd/xmgl/modules/risk/mapper/xml/RiskListSourceMapper.xml +++ b/src/main/java/com/zhgd/xmgl/modules/risk/mapper/xml/RiskListSourceMapper.xml @@ -7,6 +7,7 @@ ,rlp.risk_point_name ,rlpat.type as accident_type_name ,rll.node_name as list_library_name + ,#{param.workable} as workable from risk_list_source t join risk_list_point rlp on rlp.id=t.point_id left join risk_list_library rll on rll.id=rlp.risk_list_library_id @@ -45,11 +46,15 @@ and - find_in_set(#{regionId},rlp.specific_responsibility_area_ids) + find_in_set(#{regionId},t.specific_responsibility_area_ids) - and t.allow_generate_task=1 and t.effective_time_begin <= now() and t.effective_time_end >= now() + and t.allow_generate_task=1 and t.effective_time_begin <= current_date and t.effective_time_end >= + current_date + + + and t.effective_time_begin <= current_date and t.effective_time_end >= current_date )t ${ew.customSqlSegment} @@ -61,4 +66,40 @@ )t where t.id = #{id} + + + + diff --git a/src/main/java/com/zhgd/xmgl/modules/risk/service/IRiskListSourceService.java b/src/main/java/com/zhgd/xmgl/modules/risk/service/IRiskListSourceService.java index 2743979b1..b985433af 100644 --- a/src/main/java/com/zhgd/xmgl/modules/risk/service/IRiskListSourceService.java +++ b/src/main/java/com/zhgd/xmgl/modules/risk/service/IRiskListSourceService.java @@ -2,8 +2,10 @@ package com.zhgd.xmgl.modules.risk.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; +import com.zhgd.xmgl.base.entity.vo.SectorOneVo; +import com.zhgd.xmgl.base.entity.vo.SectorVo; import com.zhgd.xmgl.modules.risk.entity.RiskListSource; -import com.zhgd.xmgl.modules.risk.entity.vo.RegionV2Vo; +import com.zhgd.xmgl.modules.risk.entity.vo.CountRisksByLevelVo; import com.zhgd.xmgl.modules.risk.entity.vo.RiskListSourceVo; import com.zhgd.xmgl.modules.risk.entity.vo.RiskUndoneVo; @@ -68,4 +70,10 @@ public interface IRiskListSourceService extends IService { List getUndoneList(HashMap param); void addUsersNotice(List sourceVos); + + CountRisksByLevelVo countRisksByLevel(HashMap param); + + List getRiskTrendChart(HashMap param); + + SectorVo countRisksByLibrary(HashMap map); } diff --git a/src/main/java/com/zhgd/xmgl/modules/risk/service/impl/RiskListPointServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/risk/service/impl/RiskListPointServiceImpl.java index e14dc1339..fcfe0a4e2 100644 --- a/src/main/java/com/zhgd/xmgl/modules/risk/service/impl/RiskListPointServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/risk/service/impl/RiskListPointServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -20,6 +21,7 @@ import com.zhgd.xmgl.modules.risk.service.IRiskListSourceService; import com.zhgd.xmgl.util.MapBuilder; import com.zhgd.xmgl.util.PageUtil; import com.zhgd.xmgl.util.RefUtil; +import org.apache.commons.collections.MapUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -48,6 +50,14 @@ public class RiskListPointServiceImpl extends ServiceImpl queryPageList(HashMap param) { + String containLibraryIds = MapUtils.getString(param, "containLibraryIds"); + if (StrUtil.isNotBlank(containLibraryIds)) { + param.put("containLibraryIdList", StrUtil.split(containLibraryIds, ",")); + } + String regionIds = MapUtils.getString(param, "regionIds"); + if (StrUtil.isNotBlank(regionIds)) { + param.put("regionIdList", StrUtil.split(regionIds, ",")); + } QueryWrapper queryWrapper = this.getQueryWrapper(param); Page page = PageUtil.getPage(param); IPage pageList = baseMapper.queryList(page, queryWrapper, param); @@ -99,6 +109,12 @@ public class RiskListPointServiceImpl extends ServiceImpl() + .set(RiskListPoint::getActivityFrequency, point.getActivityFrequency()) + .set(RiskListPoint::getEffectiveTimeBegin, point.getEffectiveTimeBegin()) + .set(RiskListPoint::getEffectiveTimeEnd, point.getEffectiveTimeEnd()) + .eq(RiskListPoint::getId, point.getId()) + ); } @Override @@ -107,6 +123,11 @@ public class RiskListPointServiceImpl extends ServiceImpl() + .eq(RiskListSource::getPointId, id)); + if (count > 0) { + throw new OpenAlertException("请先删除辨识的危险源"); + } baseMapper.deleteById(id); } diff --git a/src/main/java/com/zhgd/xmgl/modules/risk/service/impl/RiskListSourceServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/risk/service/impl/RiskListSourceServiceImpl.java index 3a3f47d8f..39c31229e 100644 --- a/src/main/java/com/zhgd/xmgl/modules/risk/service/impl/RiskListSourceServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/risk/service/impl/RiskListSourceServiceImpl.java @@ -2,15 +2,20 @@ package com.zhgd.xmgl.modules.risk.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; +import cn.hutool.core.date.DateField; +import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.zhgd.jeecg.common.execption.OpenAlertException; import com.zhgd.jeecg.common.system.query.QueryGenerator; +import com.zhgd.xmgl.base.entity.vo.SectorOneVo; +import com.zhgd.xmgl.base.entity.vo.SectorVo; import com.zhgd.xmgl.modules.basicdata.entity.SystemUser; import com.zhgd.xmgl.modules.basicdata.service.INoticeService; import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService; @@ -18,10 +23,7 @@ import com.zhgd.xmgl.modules.risk.entity.RiskListPoint; import com.zhgd.xmgl.modules.risk.entity.RiskListSource; import com.zhgd.xmgl.modules.risk.entity.RiskListSourceUnbuilt; import com.zhgd.xmgl.modules.risk.entity.RiskListWorkable; -import com.zhgd.xmgl.modules.risk.entity.vo.RegionV2Vo; -import com.zhgd.xmgl.modules.risk.entity.vo.RiskListLibraryVo; -import com.zhgd.xmgl.modules.risk.entity.vo.RiskListSourceVo; -import com.zhgd.xmgl.modules.risk.entity.vo.RiskUndoneVo; +import com.zhgd.xmgl.modules.risk.entity.vo.*; import com.zhgd.xmgl.modules.risk.mapper.RiskListSourceMapper; import com.zhgd.xmgl.modules.risk.service.*; import com.zhgd.xmgl.modules.xz.security.entity.XzSecurityQualityInspectionRecord; @@ -34,6 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -179,6 +182,12 @@ public class RiskListSourceServiceImpl extends ServiceImpl() + .set(RiskListSource::getActivityFrequency, source.getActivityFrequency()) + .set(RiskListSource::getEffectiveTimeBegin, source.getEffectiveTimeBegin()) + .set(RiskListSource::getEffectiveTimeEnd, source.getEffectiveTimeEnd()) + .eq(RiskListSource::getId, source.getId()) + ); } @Override @@ -270,4 +279,43 @@ public class RiskListSourceServiceImpl extends ServiceImpl param) { + return baseMapper.countRisksByLevel(param); + } + + @Override + public List getRiskTrendChart(HashMap param) { + List sources = this.list(new LambdaQueryWrapper() + .select(RiskListSource::getId, RiskListSource::getEffectiveTimeBegin, RiskListSource::getEffectiveTimeEnd) + .eq(RiskListSource::getProjectSn, MapUtils.getString(param, "projectSn")) + .le(RiskListSource::getEffectiveTimeBegin, MapUtils.getString(param, "endTime") + "-31 23:59:59") + .ge(RiskListSource::getEffectiveTimeEnd, MapUtils.getString(param, "startTime") + "-01 00:00:00") + ).stream().sorted(Comparator.comparing(RiskListSource::getEffectiveTimeBegin)).collect(Collectors.toList()); + List months = DateUtil.rangeToList(DateUtil.parse(MapUtils.getString(param, "startTime")), DateUtil.parse(MapUtils.getString(param, "endTime")), DateField.MONTH); + ArrayList vos = new ArrayList<>(); + Integer lastTotal = null; + for (DateTime month : months) { + CountRisksByLevelVo vo = new CountRisksByLevelVo(); + vo.setZdNum((int) sources.stream().filter(s -> Objects.equals(s.getRiskLevel(), 1) && DateUtil.compare(s.getEffectiveTimeBegin(), month) <= 0 && DateUtil.compare(s.getEffectiveTimeEnd(), month) >= 0).count()); + vo.setJdNum((int) sources.stream().filter(s -> Objects.equals(s.getRiskLevel(), 2) && DateUtil.compare(s.getEffectiveTimeBegin(), month) <= 0 && DateUtil.compare(s.getEffectiveTimeEnd(), month) >= 0).count()); + vo.setYbNum((int) sources.stream().filter(s -> Objects.equals(s.getRiskLevel(), 3) && DateUtil.compare(s.getEffectiveTimeBegin(), month) <= 0 && DateUtil.compare(s.getEffectiveTimeEnd(), month) >= 0).count()); + vo.setDNum((int) sources.stream().filter(s -> Objects.equals(s.getRiskLevel(), 4) && DateUtil.compare(s.getEffectiveTimeBegin(), month) <= 0 && DateUtil.compare(s.getEffectiveTimeEnd(), month) >= 0).count()); + vo.setTotal((int) sources.stream().filter(s -> DateUtil.compare(s.getEffectiveTimeBegin(), month) <= 0 && DateUtil.compare(s.getEffectiveTimeEnd(), month) >= 0).count()); + vo.setYearMonth(DateUtil.format(month, "yyyy-MM")); + if (lastTotal != null) { + vo.setMoMChange(lastTotal != 0 ? new BigDecimal((vo.getTotal() * 1.0 / lastTotal - 1) * 100).setScale(2, BigDecimal.ROUND_HALF_UP) : null); + } + lastTotal = vo.getTotal(); + vos.add(vo); + } + return vos; + } + + @Override + public SectorVo countRisksByLibrary(HashMap map) { + List list = baseMapper.countRisksByLibrary(map); + return SectorVo.getSectorVo(list); + } } diff --git a/src/main/resources/excel/辨识清单导出模板.xlsx b/src/main/resources/excel/辨识清单导出模板.xlsx index 2d6156960..484ca5dd4 100644 Binary files a/src/main/resources/excel/辨识清单导出模板.xlsx and b/src/main/resources/excel/辨识清单导出模板.xlsx differ