Commit 6f426532 authored by litengwei's avatar litengwei

Merge remote-tracking branch 'origin/develop_dl' into develop_dl

parents ee7ac92b c8659138
package com.yeejoin.equipmanage.common.entity.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "消防资源监管子项DTO", description = "消防资源监管子项DTO")
public class FireResourceStatsDTO {
@ApiModelProperty(value = "资源总数")
private long totalCounts;
@ApiModelProperty(value = "黄码资源数")
private long yellowCounts;
@ApiModelProperty(value = "红码资源数")
private long redCounts;
@ApiModelProperty(value = "异常百分比", notes = "非正常资源数/资源总数, 非正常资源数=黄码资源数+红码资源数")
private Number abnormalRatio;
}
package com.yeejoin.amos.boot.module.jcs.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
public interface FireResourceSupervisionMapper extends BaseMapper<OrgUsr> {
List<Map<String, Object>> selectPersonnelStats(@Param("bizOrgCode") String bizOrgCode);
Long selectTodayAttendance(@Param("bizOrgCode") String bizOrgCode);
}
package com.yeejoin.amos.boot.module.jcs.api.service;
import java.util.Map;
/**
* 消防资源监管
*/
public interface IFireResourceSupervisionService {
/**
* 获取人员统计信息
*
* @param bizOrgCode 机构编码
*/
Map<String, Map<String, Number>> getPersonnelStats(String bizOrgCode);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jcs.api.mapper.FireResourceSupervisionMapper">
<select id="selectPersonnelStats" resultType="java.util.HashMap">
SELECT
IF(dfi.field_value = 1601, 1, IF(dfi.field_value = 1602, 0, -1)) AS peopleType,
COUNT(DISTINCT u.sequence_nbr) AS totalCount,
SUM(IF(ISNULL(cfp.post_qualification), 0, 1)) AS certifiedCount
FROM
cb_org_usr u
INNER JOIN cb_dynamic_form_instance dfi ON dfi.instance_id = u.sequence_nbr AND dfi.field_code = 'peopleType'
LEFT JOIN cb_firefighters_post cfp ON cfp.org_usr_id = u.sequence_nbr AND cfp.is_delete = false
WHERE
u.is_delete = false
AND u.biz_org_code LIKE CONCAT(#{bizOrgCode}, '%')
GROUP BY
peopleType
HAVING peopleType in (0, 1);
</select>
<select id="selectTodayAttendance" resultType="java.lang.Long">
SELECT COUNT(DISTINCT cs.user_id)
FROM cb_sign cs
WHERE cs.date = date_format(now(), '%Y-%m-%d')
AND cs.is_delete = FALSE
AND cs.org_code like concat(#{bizOrgCode}, '%')
</select>
</mapper>
......@@ -3,6 +3,7 @@ package com.yeejoin.equipmanage.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.equipmanage.common.entity.dto.OrgUsrDto;
import com.yeejoin.equipmanage.common.entity.publics.CommonResponse;
import com.yeejoin.equipmanage.common.utils.*;
import com.yeejoin.equipmanage.config.PersonIdentify;
import com.yeejoin.equipmanage.mapper.FireFightingSystemMapper;
......@@ -204,4 +205,13 @@ public class DCenterController extends AbstractBaseController {
return CommonResponseUtil.success(menus);
}
@GetMapping("/water/statics")
@ApiOperation(value = "消防水源信息")
@TycloudOperation(ApiLevel = UserType.AGENCY)
public ResponseModel getFireWaterStatics() {
ReginParams reginParams = getSelectedOrgInfo();
String bizOrgCode = !ValidationUtil.isEmpty(reginParams.getPersonIdentity()) && StringUtil.isNotEmpty(reginParams.getPersonIdentity().getBizOrgCode()) ? reginParams.getPersonIdentity().getBizOrgCode() : null;
return CommonResponseUtil.success(fireFightingSystemService.getFireWaterStatics(bizOrgCode));
}
}
package com.yeejoin.equipmanage.controller;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.equipmanage.common.entity.dto.FireResourceStatsDTO;
import com.yeejoin.equipmanage.service.IFireResourceSupervisionService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.HashMap;
import java.util.Map;
@Slf4j
@RestController
@RequestMapping(value = "/fire-resource-superv")
public class FireResourceSupervisionController extends BaseController {
@Autowired
private IFireResourceSupervisionService iFireResourceSupervisionService;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "消防系统、检测部件、消防车辆统计信息查询", notes = "聚合接口: 消防系统、检测部件、消防车辆统计信息查询")
@RequestMapping(value = "/stats", method = RequestMethod.GET)
public ResponseModel<Object> stats() {
String orgCode = this.getOrgCode();
FireResourceStatsDTO fireSystemStats = iFireResourceSupervisionService.getFireSystemStats(orgCode);
FireResourceStatsDTO monitorComponentStats = iFireResourceSupervisionService.getMonitorComponentStats(orgCode);
FireResourceStatsDTO fireCarStats = iFireResourceSupervisionService.getFireCarStats(orgCode);
Map<String, FireResourceStatsDTO> result = new HashMap<String, FireResourceStatsDTO>() {{
put("fireSystemStats", fireSystemStats);
put("monitorComponentStats", monitorComponentStats);
put("fireCarStats", fireCarStats);
}};
return ResponseHelper.buildResponse(result);
}
}
......@@ -680,4 +680,12 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE
Map<String, Object> selectEquipmentSpecificById(@Param("id") String id);
void updateStatusById(@Param("id") String id, @Param("status") String status);
Map<String, Object> getFireWaterStatics(@Param("bizOrgCode") String bizOrgCode);
Map<String, Object> selectFireFightingSystemStats(@Param("bizOrgCode") String bizOrgCode);
Map<String, Object> selectEquipmentSpecificStats(@Param("bizOrgCode") String bizOrgCode);
Map<String, Object> selectCarStats(@Param("bizOrgCode") String bizOrgCode);
}
......@@ -317,4 +317,6 @@ public interface IFireFightingSystemService extends IService<FireFightingSystemE
*/
void resetMorphic();
Map<String, Object> getFireWaterStatics(String bizOrgCode);
}
package com.yeejoin.equipmanage.service;
import com.yeejoin.equipmanage.common.entity.dto.FireResourceStatsDTO;
/**
* 消防资源监管
*/
public interface IFireResourceSupervisionService {
/**
* 消防系统信息
* @param bizOrgCode 机构编码
*/
FireResourceStatsDTO getFireSystemStats(String bizOrgCode);
/**
* 监测部件
* @param bizOrgCode 机构编码
*/
FireResourceStatsDTO getMonitorComponentStats(String bizOrgCode);
/**
* 消防车辆
* @param bizOrgCode 机构编码
*/
FireResourceStatsDTO getFireCarStats(String bizOrgCode);
}
......@@ -2456,4 +2456,20 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
}
}
@Override
public Map<String, Object> getFireWaterStatics(String bizOrgCode) {
Map<String, Object> map = new HashMap<>();
Map<String, Object> resultMap = fireFightingSystemMapper.getFireWaterStatics(bizOrgCode);
map.put("total", resultMap.get("total"));
map.put("redCode", resultMap.get("redCode"));
map.put("yellowCode", resultMap.get("yellowCode"));
BigDecimal total = new BigDecimal(String.valueOf(resultMap.get("total")));
BigDecimal redNum = new BigDecimal(String.valueOf(resultMap.get("redCode")));
BigDecimal yellowNum = new BigDecimal(String.valueOf(resultMap.get("yellowCode")));
BigDecimal errorNum = redNum.add(yellowNum);
BigDecimal ratePercent = errorNum.divide(total, 2, BigDecimal.ROUND_HALF_UP);
map.put("ratePercent", ratePercent + "%");
return map;
}
}
package com.yeejoin.equipmanage.service.impl;
import com.yeejoin.equipmanage.common.entity.dto.FireResourceStatsDTO;
import com.yeejoin.equipmanage.mapper.FireFightingSystemMapper;
import com.yeejoin.equipmanage.service.IFireResourceSupervisionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.Map;
@Slf4j
@Service
public class IFireResourceSupervisionServiceImpl implements IFireResourceSupervisionService {
@Autowired
private FireFightingSystemMapper fireFightingSystemMapper;
/**
* 消防系统信息
*
* @param bizOrgCode 机构编码
*/
@Override
public FireResourceStatsDTO getFireSystemStats(String bizOrgCode) {
Map<String, Object> resultMap = fireFightingSystemMapper.selectFireFightingSystemStats(bizOrgCode);
return buildFireResourceStatsDTO(resultMap);
}
/**
* 监测部件
*
* @param bizOrgCode 机构编码
*/
@Override
public FireResourceStatsDTO getMonitorComponentStats(String bizOrgCode) {
Map<String, Object> resultMap = fireFightingSystemMapper.selectEquipmentSpecificStats(bizOrgCode);
return buildFireResourceStatsDTO(resultMap);
}
/**
* 消防车辆
*
* @param bizOrgCode 机构编码
*/
@Override
public FireResourceStatsDTO getFireCarStats(String bizOrgCode) {
Map<String, Object> resultMap = fireFightingSystemMapper.selectCarStats(bizOrgCode);
return buildFireResourceStatsDTO(resultMap);
}
private FireResourceStatsDTO buildFireResourceStatsDTO(Map<String, Object> resultMap) {
FireResourceStatsDTO fireResourceStats = new FireResourceStatsDTO();
fireResourceStats.setTotalCounts((long) resultMap.get("totalCount"));
fireResourceStats.setYellowCounts((long) resultMap.get("yellowCodeCount"));
fireResourceStats.setRedCounts((long) resultMap.get("redCodeCount"));
long expCount = fireResourceStats.getYellowCounts() + fireResourceStats.getRedCounts();
double abnormalRatio = 0;
if (fireResourceStats.getTotalCounts() != 0 && expCount != 0) {
abnormalRatio = (double) expCount / fireResourceStats.getTotalCounts() * 100;
}
if (abnormalRatio == 0) {
fireResourceStats.setAbnormalRatio(0);
} else {
DecimalFormat decimalFormat = new DecimalFormat("#.00");
decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
String formattedRatio = decimalFormat.format(abnormalRatio);
fireResourceStats.setAbnormalRatio(Double.parseDouble(formattedRatio));
}
return fireResourceStats;
}
}
......@@ -47,6 +47,7 @@ import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
......@@ -177,9 +178,6 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
CarMapper carMapper;
@Autowired
IMainIotMonitorSerivce iMainIotMonitorSerivce;
@Autowired
private ISyncDataService syncDataService;
@Autowired
......
package com.yeejoin.amos.boot.module.jcs.biz.controller;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jcs.api.service.IFireResourceSupervisionService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.Map;
@Slf4j
@RestController
@RequestMapping("/fire-resource-superv")
public class FireResourceSupervisionController extends BaseController {
@Autowired
private IFireResourceSupervisionService iFireResourceSupervisionService;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "驻站消防员、运维人员统计信息查询", notes = "驻站消防员、运维人员统计信息查询")
@RequestMapping(value = "/stats", method = RequestMethod.GET)
public ResponseModel<Object> stats() {
String orgCode = this.getOrgCode();
Map<String, Map<String, Number>> personnelStats = iFireResourceSupervisionService.getPersonnelStats(orgCode);
return ResponseHelper.buildResponse(personnelStats);
}
}
package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.yeejoin.amos.boot.module.jcs.api.mapper.FireResourceSupervisionMapper;
import com.yeejoin.amos.boot.module.jcs.api.service.IFireResourceSupervisionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Service
public class FireResourceSupervisionServiceImpl implements IFireResourceSupervisionService {
@Autowired
private FireResourceSupervisionMapper fireResourceSupervisionMapper;
/**
* 获取人员统计信息
*
* @param bizOrgCode 机构编码
*/
@Override
public Map<String, Map<String, Number>> getPersonnelStats(String bizOrgCode) {
List<Map<String, Object>> maps = fireResourceSupervisionMapper.selectPersonnelStats(bizOrgCode);
Long attendanceCount = fireResourceSupervisionMapper.selectTodayAttendance(bizOrgCode);
Map<String, Map<String, Number>> result = new HashMap<>();
for (Map<String, Object> map : maps) {
Object peopleType = map.get("peopleType");
if (Objects.isNull(peopleType)) {
continue;
}
long totalCount = Long.parseLong(map.get("totalCount").toString());
long certifiedCount = Long.parseLong(map.get("certifiedCount").toString());
Map<String, Number> stats = getStringNumberMap(certifiedCount, totalCount, attendanceCount);
String key;
switch (peopleType.toString()) {
case "0":
key = "operationStats";
break;
case "1":
key = "fireStats";
break;
default:
continue;
}
result.put(key, stats);
}
return result;
}
private Map<String, Number> getStringNumberMap(long certifiedCount, long totalCount, Long attendanceCount) {
Map<String, Number> stats = new HashMap<>();
stats.put("totalCount", totalCount);
stats.put("certifiedRate", calculateRate(certifiedCount, totalCount));
stats.put("attendanceRate", calculateRate(attendanceCount, totalCount));
stats.put("monthStudyRate", BigDecimal.ZERO);
return stats;
}
private BigDecimal calculateRate(Number numerator, Number denominator) {
BigDecimal rate = new BigDecimal(numerator.toString())
.divide(new BigDecimal(denominator.toString()), 4, RoundingMode.HALF_UP)
.multiply(new BigDecimal(100))
.setScale(2, RoundingMode.HALF_UP);
return rate.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO : rate;
}
}
......@@ -34,4 +34,12 @@ public class ControlScreenController extends AbstractBaseController {
}
return CommonResponseUtil.success(iPlanTaskService.firePatrolStatics(bizOrgCode));
}
@GetMapping("/statics")
@ApiOperation(value = "消防运维信息")
@TycloudOperation(ApiLevel = UserType.AGENCY)
public CommonResponse getStatics(@RequestParam(required = false) String companyCode) {
return CommonResponseUtil.success(iPlanTaskService.getStatics(companyCode));
}
}
......@@ -216,4 +216,9 @@ public interface PlanTaskMapper extends BaseMapper {
List<Map<String, Object>> getCheckNotQualifiedEquipInfo(@Param(value="taskDetailId") String taskDetailId);
String getCheckIdByDetailId(@Param(value="taskDetailId") String taskDetailId);
String queryByCompanyCode(@Param("companyCode") String companyCode);
List<Map<String, Object>> getStatics(@Param("bizOrgCode") String bizOrgCode);
}
......@@ -2028,6 +2028,16 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
return map;
}
@Override
public List<Map<String, Object>> getStatics(String companyCode) {
String bizOrgCode = null;
if (StringUtil.isNotEmpty(companyCode)) {
bizOrgCode = planTaskMapper.queryByCompanyCode(companyCode);
}
return planTaskMapper.getStatics(bizOrgCode);
}
public static byte[] file2byte(File file) {
try {
FileInputStream in = new FileInputStream(file);
......
......@@ -187,6 +187,8 @@ public interface IPlanTaskService {
*/
List<Map<String,Object>> firePatrolStatics(String bizOrgCode);
List<Map<String,Object>> getStatics(String companyCode);
/**
* 计划执行查询
*/
......
......@@ -5894,4 +5894,72 @@
update f_fire_fighting_system set system_status = #{status} where id = #{id}
</update>
<select id="getFireWaterStatics" resultType="java.util.Map">
select
(select
count(sequence_nbr)
from
cb_water_resource
<where>
<if test="bizOrgCode != null and bizOrgCode != ''">
biz_org_code like concat(#{bizOrgCode}, '%')
</if>
</where>
) AS total,
(select
count(sequence_nbr)
from
cb_water_resource
<where>
water_status = '2'
<if test="bizOrgCode != null and bizOrgCode != ''">
AND biz_org_code like concat(#{bizOrgCode}, '%')
</if>
</where>
) AS redCode,
(select
count(sequence_nbr)
from
cb_water_resource
<where>
water_status = '1'
<if test="bizOrgCode != null and bizOrgCode != ''">
AND biz_org_code like concat(#{bizOrgCode}, '%')
</if>
</where>
) AS yellowCode
</select>
<select id="selectFireFightingSystemStats" resultType="java.util.Map">
SELECT
COUNT(*) AS totalCount,
-- COUNT(CASE WHEN ffs.equip_status = '1' THEN 1 END) AS yellowCodeCount,
-- COUNT(CASE WHEN ffs.equip_status = '2' THEN 1 END) AS redCodeCount,
0 AS yellowCodeCount,
0 AS redCodeCount
FROM f_fire_fighting_system ffs
WHERE ffs.biz_org_code LIKE CONCAT(#{bizOrgCode}, '%')
</select>
<select id="selectEquipmentSpecificStats" resultType="java.util.Map">
SELECT
COUNT(*) AS totalCount,
COUNT( CASE WHEN wes.equip_status = '1' THEN 1 END ) AS yellowCodeCount,
COUNT( CASE WHEN wes.equip_status = '2' THEN 1 END ) AS redCodeCount
FROM
wl_equipment_specific wes
WHERE
wes.biz_org_code LIKE CONCAT(#{bizOrgCode}, '%')
</select>
<select id="selectCarStats" resultType="java.util.Map">
SELECT
COUNT(*) AS totalCount,
0 AS yellowCodeCount,
0 AS redCodeCount
FROM
wl_car wc
WHERE
wc.biz_org_code LIKE CONCAT(#{bizOrgCode}, '%')
</select>
</mapper>
......@@ -1354,4 +1354,82 @@
<select id="getCheckIdByDetailId" resultType="java.lang.String">
select id from p_check where plan_task_detail_id = #{taskDetailId} limit 1
</select>
<select id="getStatics" resultType="java.util.Map">
SELECT
'1' AS `key`,
ifnull( sum( `p_plan_task`.`finish_num` ), 0 ) AS `value`,
'' AS unit,
'今日累计巡查点位' AS `name`,
'xfxcjrljxcdw' AS code
FROM
`p_plan_task`
WHERE
DATE_FORMAT( check_date, '%Y-%m-%d' ) = CURRENT_DATE ()
<if test="bizOrgCode != null and bizOrgCode != ''">
AND org_code LIKE CONCAT(#{bizOrgCode}, '%')
</if>
UNION ALL
SELECT
ifnull( sum( ppk.`point_num` ), 0 ) AS `value`,
'' AS unit,
'合格' AS `name`,
'xfxchg' AS code,
'2' AS `key`
FROM
`p_plan_task` ppk
LEFT JOIN p_plan_task_detail pptd ON pptd.task_no = ppk.id
WHERE
DATE_FORMAT( check_date, '%Y-%m-%d' ) = CURRENT_DATE () AND pptd.STATUS = 1
<if test="bizOrgCode != null and bizOrgCode != ''">
AND org_code LIKE CONCAT(#{bizOrgCode}, '%')
</if>
UNION ALL
SELECT
'' AS `value`,
'%' AS unit,
'合格占比' AS `name`,
'xfxchgzb' AS code,
'3' AS `key`
UNION ALL
SELECT
'' AS `value`,
'' AS unit,
'不合格' AS `name`,
'xfxcbhg' AS code,
'4' AS `key`
UNION ALL
SELECT
ifnull( sum( `p_plan_task`.`point_num` ), 0 ) AS `value`,
'' AS unit,
'今日漏查点位' AS `name`,
'currentDayMiss' AS `indexKey`,
'xfxcjrlcdw' AS code,
'5' AS `key`
FROM
`p_plan_task`
WHERE
`finish_status` = 3
AND DATE_FORMAT( check_date, '%Y-%m-%d' ) = CURRENT_DATE ()
<if test="bizOrgCode != null and bizOrgCode != ''">
AND org_code LIKE CONCAT(#{bizOrgCode}, '%')
</if>
UNION ALL
SELECT
'' AS `value`,
'' AS unit,
'漏查率' AS `name`,
'xfxclcl' AS code,
'6' AS `key`
</select>
<select id="queryByCompanyCode" resultType="java.lang.String">
SELECT biz_org_code
FROM cb_org_usr
WHERE is_delete = 0
<if test="companyCode != null and companyCode != ''">
AND code = #{companyCode}
</if>
</select>
</mapper>
\ No newline at end of file
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