Commit 4d2149c8 authored by tianbo's avatar tianbo

三库建设-按监管单位统计调整

parent 3689850d
......@@ -52,6 +52,11 @@ public class DPFilterParamDto {
private String superviseUnitName;
/**
* 监管单位编码(接收单位/管辖机构)
*/
private String superviseUnitCode;
/**
* 企业单位名称(发起单位/使用单位)
*/
private String companyName;
......
......@@ -18,6 +18,12 @@ public class SkjsCompanyCountItemDto {
*/
private String regionName;
/*
* 监管单位-code_name
*/
private String superviseKey;
/**
* 使用单位
*/
......
......@@ -18,6 +18,11 @@ public class SkjsEquipCountItemDto {
*/
private String regionName;
/*
* 监管单位-code_name
*/
private String superviseKey;
/**
* 电梯
*/
......
......@@ -18,6 +18,11 @@ public class SkjsUserCountItemDto {
*/
private String regionName;
/*
* 监管单位-code_name
*/
private String superviseKey;
/**
* 作业人员
*/
......
package com.yeejoin.amos.boot.module.statistics.api.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@AllArgsConstructor
@Getter
public enum RegulatoryUnitLevelEnum {
/**
* *监管单位类型
*/
省局("省局", "headquarter"),
市局("市局", "prefecture-level"),
区县局("区县局", "county");
private final String name;
private final String code;
public static Map<String, String> getName = new HashMap<>();
public static Map<String, String> getCode = new HashMap<>();
static {
for (RegulatoryUnitLevelEnum e : RegulatoryUnitLevelEnum.values()) {
getName.put(e.code, e.name);
getCode.put(e.name, e.code);
}
}
public static RegulatoryUnitLevelEnum getEnumByCode(String code) {
return Arrays.stream(RegulatoryUnitLevelEnum.values()).filter(r -> r.code.equals(code)).findFirst().orElse(null);
}
}
......@@ -46,6 +46,6 @@ public interface ZLStatisticsMapper {
IPage<IdxBizJgOtherInfo> getEquipInfoPage(IPage<IdxBizJgOtherInfo> idxBizJgOtherInfoPage);
List<CountDto> countUserByPostAndAreaCode(@Param("orgCode") String orgCode, @Param("regionCode") String regionCode);
List<CountDto> countUserByPostAndAreaCode(@Param("orgCode") String orgCode, @Param("regionCode") String regionCode, Boolean isOrgCodeExactMatch);
}
......@@ -170,7 +170,35 @@
tz_base_enterprise_info bi
WHERE
tui.unit_code = bi.use_code
and ((bi.supervise_org_code != '50' and bi.supervise_org_code LIKE CONCAT (#{orgCode}, '%')) or (bi.supervise_org_code = '50' and bi.office_region LIKE CONCAT ('%', #{regionCode}, '%')))
and
(
<choose>
<when test="regionCode != null and regionCode != ''">--按监管单位统计时,省局使用
(
<choose>
<when test="isOrgCodeExactMatch != null and isOrgCodeExactMatch != ''">
bi.supervise_org_code != '50' AND bi.supervise_org_code = #{orgCode}
</when>
<otherwise>
bi.supervise_org_code != '50' AND bi.supervise_org_code LIKE CONCAT(#{orgCode}, '%')
</otherwise>
</choose>
)
OR
(bi.supervise_org_code = '50' AND bi.office_region LIKE CONCAT('%', #{regionCode}, '%'))
</when>
<otherwise>--按监管单位统计时,除省局外使用
<choose>
<when test="isOrgCodeExactMatch != null and isOrgCodeExactMatch != ''">
bi.supervise_org_code != '50' AND bi.supervise_org_code = #{orgCode}
</when>
<otherwise>
bi.supervise_org_code != '50' AND bi.supervise_org_code LIKE CONCAT(#{orgCode}, '%')
</otherwise>
</choose>
</otherwise>
</choose>
)
and tui.is_delete=false
and bi.is_delete= '0'
group by keyStr
......
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.statistcs.biz.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamForDetailDto;
import com.yeejoin.amos.boot.module.jg.api.dto.FourColorCountDataDto;
......@@ -19,6 +20,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
import java.util.Map;
......@@ -30,7 +32,7 @@ import java.util.Map;
@RestController
@Api(tags = "大屏-监管及总览统计API")
@RequestMapping("/dp/jg")
public class JGDPStatisticsController {
public class JGDPStatisticsController extends BaseController {
private JGDPStatisticsServiceImpl statisticsService;
......@@ -632,4 +634,25 @@ public class JGDPStatisticsController {
return ResponseHelper.buildResponse(statisticsService.querySkjsDetail(dpFilterParamDto));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏总览-右侧-三库建设情况统计(柱状图)(管辖机构)", notes = "大屏总览-右侧-三库建设情况统计(柱状图)(管辖机构)")
@PostMapping(value = "/zl/skjsBySupervise")
public ResponseModel<Map<String, Object>> queryBarChartDataForSkjsBySupervise(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
return ResponseHelper.buildResponse(statisticsService.queryBarChartDataForSkjsBySupervise(dpFilterParamDto));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏总览-三库建设情况(管辖机构)-详情", notes = "大屏总览-三库建设情况(管辖机构)-详情")
@PostMapping(value = "/skjsBySupervise/detail")
public ResponseModel<Map<String, Object>> querySkjsBySuperviseDetail(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
return ResponseHelper.buildResponse(statisticsService.querySkjsBySuperviseDetail(dpFilterParamDto));
}
}
......@@ -36,7 +36,6 @@ import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import javax.validation.constraints.NotBlank;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
......@@ -895,11 +894,11 @@ public class AQZSDPStatisticsServiceImpl {
return new HashMap<>();
}
// 1.气瓶数量统计
long cylinderNum = stCommonService.staticsCenterMapCountDataForCylinder(result, orgCode,true, true);
long cylinderNum = stCommonService.staticsCenterMapCountDataForCylinder(result, orgCode,true, true, false);
//1.8大类设备数量统计,压力容器里包括气瓶所以需要特殊处理,在统计压力容器时去掉气瓶的数量
stCommonService.staticsCenterMapCountDataForEquip(result, cylinderNum, orgCode,true,true);
stCommonService.staticsCenterMapCountDataForEquip(result, cylinderNum, orgCode,true,true, false);
//2.压力管道长度统计
stCommonService.staticsCenterMapCountDataForPipeline(result, orgCode,true);
stCommonService.staticsCenterMapCountDataForPipeline(result, orgCode,true, false);
//3.单位数量统计
this.staticsCenterMapCountDataForCompany(result, orgCode, dpFilterParamDto.getCityCode());
//4.人员数量统计
......@@ -929,7 +928,7 @@ public class AQZSDPStatisticsServiceImpl {
setDefaultCompanyCountData(result);
return;
}
List<CountDto> countDtos = enterpriseInfoMapper.countByUnitTypeAndOrgCode(orgCode, cityCode);
List<CountDto> countDtos = enterpriseInfoMapper.countByUnitTypeAndOrgCode(orgCode, cityCode, false);
result.put(DPMapStatisticsItemEnum.USERS_UNITS.getCode(), countDtos.stream().filter(c -> c.getKeyStr().contains(COMPANY_TYPE_USE)).mapToInt(CountDto::getIntValue).sum());
result.put(DPMapStatisticsItemEnum.CONSTRUCTION_UNITS.getCode(), countDtos.stream().filter(c -> c.getKeyStr().contains(COMPANY_TYPE_MAINTENANCE)).mapToInt(CountDto::getIntValue).sum());
result.put(DPMapStatisticsItemEnum.MANUFACTURING_UNITS.getCode(), countDtos.stream().filter(c -> c.getKeyStr().contains(COMPANY_TYPE_MANUFACTURE)).mapToInt(CountDto::getIntValue).sum());
......@@ -990,11 +989,11 @@ public class AQZSDPStatisticsServiceImpl {
return new HashMap<>();
}
// 0. 气瓶数量统计
long cylinderNum = stCommonService.staticsCenterMapCountDataForCylinder(result, orgCode,true, true);
long cylinderNum = stCommonService.staticsCenterMapCountDataForCylinder(result, orgCode,true, true, false);
// 1. 8大类设备数量统计,压力容器里包括气瓶所以需要特殊处理,在统计压力容器时去掉气瓶的数量
stCommonService.staticsCenterMapCountDataForEquip(result, cylinderNum, orgCode,true,true);
stCommonService.staticsCenterMapCountDataForEquip(result, cylinderNum, orgCode,true,true, false);
// 2. 压力管道长度统计
stCommonService.staticsCenterMapCountDataForPipeline(result, orgCode,true);
stCommonService.staticsCenterMapCountDataForPipeline(result, orgCode,true, false);
// 3.单位数量统计
this.staticsCenterMapCountDataForCompany(result, orgCode, dpFilterParamDto.getCityCode());
// 4. 人员数量统计
......
......@@ -37,6 +37,7 @@ import com.yeejoin.amos.boot.module.statistics.api.dto.SkjsCompanyCountItemDto;
import com.yeejoin.amos.boot.module.statistics.api.dto.SkjsCountItemDto;
import com.yeejoin.amos.boot.module.statistics.api.dto.SkjsEquipCountItemDto;
import com.yeejoin.amos.boot.module.statistics.api.dto.SkjsUserCountItemDto;
import com.yeejoin.amos.boot.module.statistics.api.enums.RegulatoryUnitLevelEnum;
import com.yeejoin.amos.boot.module.statistics.api.mapper.CylinderBusinessStatisticsMapper;
import com.yeejoin.amos.boot.module.statistics.api.mapper.JGStatisticsMapper;
import com.yeejoin.amos.boot.module.statistics.api.mapper.ZLStatisticsMapper;
......@@ -186,6 +187,8 @@ public class JGDPStatisticsServiceImpl {
public static final String USE_PLACE_CODE = "USE_PLACE_CODE";
public static final String EQU_CATEGORY_CODE = "EQU_CATEGORY_CODE";
public static final String PROJECT_CONTRAPTION = "PROJECT_CONTRAPTION";// 工程装置名称
// 管辖机构redis缓存key
private static final String REGULATOR_UNIT_TREE = "REGULATOR_UNIT_TREE";
@Value("classpath:/json/registrationBasic.json")
private Resource registrationBasicJson;
......@@ -368,11 +371,11 @@ public class JGDPStatisticsServiceImpl {
return setDefaultCount(result);
}
// 1.气瓶数量统计
long cylinderNum = stCommonService.staticsCenterMapCountDataForCylinder(result, orgCode, true, true);
long cylinderNum = stCommonService.staticsCenterMapCountDataForCylinder(result, orgCode, true, true, false);
//1.8大类设备数量统计,压力容器里包括气瓶所以需要特殊处理,在统计压力容器时去掉气瓶的数量
stCommonService.staticsCenterMapCountDataForEquip(result, cylinderNum, orgCode, true, true);
stCommonService.staticsCenterMapCountDataForEquip(result, cylinderNum, orgCode, true, true, false);
//2.压力管道长度统计
stCommonService.staticsCenterMapCountDataForPipeline(result, orgCode, true);
stCommonService.staticsCenterMapCountDataForPipeline(result, orgCode, true, false);
//3.单位数量统计
this.staticsCenterMapCountDataForCompany(result, orgCode, dpFilterParamDto.getCityCode());
//4.人员数量统计
......@@ -387,11 +390,11 @@ public class JGDPStatisticsServiceImpl {
return setDefaultCount(result);
}
// 1.气瓶数量统计
long cylinderNum = stCommonService.staticsCenterMapCountDataForCylinder(result, orgCode, false, true);
long cylinderNum = stCommonService.staticsCenterMapCountDataForCylinder(result, orgCode, false, true, false);
//1.8大类设备数量统计,压力容器里包括气瓶所以需要特殊处理,在统计压力容器时去掉气瓶的数量
stCommonService.staticsCenterMapCountDataForEquip(result, cylinderNum, orgCode, false, true);
stCommonService.staticsCenterMapCountDataForEquip(result, cylinderNum, orgCode, false, true, false);
//2.压力管道长度统计
stCommonService.staticsCenterMapCountDataForPipeline(result, orgCode, false);
stCommonService.staticsCenterMapCountDataForPipeline(result, orgCode, false, false);
return result;
}
......@@ -402,11 +405,11 @@ public class JGDPStatisticsServiceImpl {
return setDefaultCount(result);
}
// 0. 气瓶数量统计
long cylinderNum = stCommonService.staticsCenterMapCountDataForCylinder(result, orgCode, true, true);
long cylinderNum = stCommonService.staticsCenterMapCountDataForCylinder(result, orgCode, true, true, false);
// 1. 8大类设备数量统计,压力容器里包括气瓶所以需要特殊处理,在统计压力容器时去掉气瓶的数量
stCommonService.staticsCenterMapCountDataForEquip(result, cylinderNum, orgCode, true, true);
stCommonService.staticsCenterMapCountDataForEquip(result, cylinderNum, orgCode, true, true, false);
// 2. 压力管道长度统计
stCommonService.staticsCenterMapCountDataForPipeline(result, orgCode, true);
stCommonService.staticsCenterMapCountDataForPipeline(result, orgCode, true, false);
// 3. 人员数量统计
this.staticsCenterMapCountDataForPerson(result, dpFilterParamDto, orgCode);
return result;
......@@ -444,7 +447,7 @@ public class JGDPStatisticsServiceImpl {
setDefaultCompanyCountData(result);
return;
}
List<CountDto> countDtos = enterpriseInfoMapper.countByUnitTypeAndOrgCode(orgCode, cityCode);
List<CountDto> countDtos = enterpriseInfoMapper.countByUnitTypeAndOrgCode(orgCode, cityCode, false);
result.put(DPMapStatisticsItemEnum.USERS_UNITS.getCode(), countDtos.stream().filter(c -> c.getKeyStr().contains(COMPANY_TYPE_USE) || c.getKeyStr().contains(COMPANY_TYPE_PERSON)).mapToInt(CountDto::getIntValue).sum());
result.put(DPMapStatisticsItemEnum.CONSTRUCTION_UNITS.getCode(), countDtos.stream().filter(c -> c.getKeyStr().contains(COMPANY_TYPE_MAINTENANCE)).mapToInt(CountDto::getIntValue).sum());
result.put(DPMapStatisticsItemEnum.MANUFACTURING_UNITS.getCode(), countDtos.stream().filter(c -> c.getKeyStr().contains(COMPANY_TYPE_MANUFACTURE)).mapToInt(CountDto::getIntValue).sum());
......@@ -453,7 +456,7 @@ public class JGDPStatisticsServiceImpl {
}
private void staticsCompanyForSkjs(SkjsCountItemDto countItemDto, String orgCode, String cityCode) {
List<CountDto> countDtos = enterpriseInfoMapper.countByUnitTypeAndOrgCode(orgCode, cityCode);
List<CountDto> countDtos = enterpriseInfoMapper.countByUnitTypeAndOrgCode(orgCode, cityCode, false);
int u1 = countDtos.stream().filter(c -> c.getKeyStr().contains(COMPANY_TYPE_USE) || c.getKeyStr().contains(COMPANY_TYPE_PERSON)).mapToInt(CountDto::getIntValue).sum();
int u2 = countDtos.stream().filter(c -> c.getKeyStr().contains(COMPANY_TYPE_MAINTENANCE)).mapToInt(CountDto::getIntValue).sum();
int u3 = countDtos.stream().filter(c -> c.getKeyStr().contains(COMPANY_TYPE_MANUFACTURE)).mapToInt(CountDto::getIntValue).sum();
......@@ -1691,11 +1694,11 @@ public class JGDPStatisticsServiceImpl {
return new HashMap<>();
}
// 0.气瓶数量统计
long cylinderNum = stCommonService.staticsCenterMapCountDataForCylinder(result, orgCode, true, true);
long cylinderNum = stCommonService.staticsCenterMapCountDataForCylinder(result, orgCode, true, true, false);
// 1.8大类设备数量统计,压力容器里包括气瓶所以需要特殊处理,在统计压力容器时去掉气瓶的数量
stCommonService.staticsCenterMapCountDataForEquip(result, cylinderNum, orgCode, true, true);
stCommonService.staticsCenterMapCountDataForEquip(result, cylinderNum, orgCode, true, true, false);
// 2.压力管道长度统计
stCommonService.staticsCenterMapCountDataForPipeline(result, orgCode, true);
stCommonService.staticsCenterMapCountDataForPipeline(result, orgCode, true, false);
// 3.已纳管设备总数
this.staticsCenterMapCountDataForEquipIsManage(result);
// 4.登记证总数
......@@ -3604,13 +3607,13 @@ public class JGDPStatisticsServiceImpl {
Map<String, Object> data = new HashMap<>();
// 查询各自统计数据作为Y轴数据
// 0. 气瓶数量统计
long cylinderNum = stCommonService.staticsCenterMapCountDataForCylinder(data, orgCode, false, false);
long cylinderNum = stCommonService.staticsCenterMapCountDataForCylinder(data, orgCode, false, false, false);
countItemDto.setCylinder(String.valueOf(cylinderNum));
// 1. 设备数量统计
long oneSetNum = stCommonService.staticsCenterMapCountDataForEquip(data, cylinderNum, orgCode, true, false);
long oneSetNum = stCommonService.staticsCenterMapCountDataForEquip(data, cylinderNum, orgCode, true, false, false);
countItemDto.setOneSet(String.valueOf(oneSetNum));
// 2. 压力管道长度统计
countItemDto.setPipeline(stCommonService.staticsCenterMapCountDataForPipeline(data, orgCode, true));
countItemDto.setPipeline(stCommonService.staticsCenterMapCountDataForPipeline(data, orgCode, true, false));
// 3. 单位数量统计
this.staticsCompanyForSkjs(countItemDto, orgCode, regionCode);
// 4. 人员数量统计
......@@ -3685,13 +3688,16 @@ public class JGDPStatisticsServiceImpl {
SkjsEquipCountItemDto countItemDto = new SkjsEquipCountItemDto();
countItemDto.setRegionCode(regionCode);
countItemDto.setRegionName(r.getRegionName());
countItemDto.setSuperviseKey(regionCode + "_" + r.getRegionName());
if (!ValidationUtil.isEmpty(orgCode)) {
Map<String, Object> data = new HashMap<>();
// 是否按监管机构代码精确匹配
Boolean isOrgBranchCodeExactMatch = !ValidationUtil.isEmpty(RegulatoryUnitLevelEnum.getEnumByCode(r.getLevel()));
// 0. 气瓶数量统计
long cylinderNum = stCommonService.staticsCenterMapCountDataForCylinder(data, orgCode, false, false);
long cylinderNum = stCommonService.staticsCenterMapCountDataForCylinder(data, orgCode, false, false, isOrgBranchCodeExactMatch);
countItemDto.setQp(String.valueOf(cylinderNum));
// 1. 设备数量统计-台套
stCommonService.staticsCenterMapCountDataForEquip(data, cylinderNum, orgCode, true, false);
stCommonService.staticsCenterMapCountDataForEquip(data, cylinderNum, orgCode, true, false, isOrgBranchCodeExactMatch);
countItemDto.setDt(String.valueOf(data.get(DPMapStatisticsItemEnum.ELEVATORS.getCode())));
countItemDto.setQzjx(String.valueOf(data.get(DPMapStatisticsItemEnum.LIFTING_MACHINERY.getCode())));
countItemDto.setKysd(String.valueOf(data.get(DPMapStatisticsItemEnum.PASSENGER_ROPEWAYS.getCode())));
......@@ -3700,7 +3706,7 @@ public class JGDPStatisticsServiceImpl {
countItemDto.setGl(String.valueOf(data.get(DPMapStatisticsItemEnum.BOILERS.getCode())));
countItemDto.setYlrq(String.valueOf(data.get(DPMapStatisticsItemEnum.PRESSURE_VESSELS.getCode())));
// 2. 压力管道长度统计
countItemDto.setYlgd(stCommonService.staticsCenterMapCountDataForPipeline(data, orgCode, true));
countItemDto.setYlgd(stCommonService.staticsCenterMapCountDataForPipeline(data, orgCode, true, isOrgBranchCodeExactMatch));
} else {
countItemDto.setDefaultValues();
}
......@@ -3717,12 +3723,23 @@ public class JGDPStatisticsServiceImpl {
// 多线程处理
Map<String, SkjsCompanyCountItemDto> companyCountItemDtoMap = regionModels.parallelStream().map(r -> {
String regionCode = r.getRegionCode().toString();
String conditionRegionCode = regionCode;
String orgCode = stCommonService.getAndSetOrgCode(regionCode);
// 按管辖机构统计企业数量时:检验检测机构直接归属省局管辖,则只有省局才统计检验检测机构数量。其他地市区县不统计
// 只有按监管单位统计(r.getLevel()为空或者为省市区县级)才需要判断是否传regionCode
if (!ValidationUtil.isEmpty(RegulatoryUnitLevelEnum.getEnumByCode(r.getLevel())) || ValidationUtil.isEmpty(r.getLevel())) {
if (!RegulatoryUnitLevelEnum.省局.getCode().equals(r.getLevel())) {
conditionRegionCode = null;
}
}
// 按管辖机构统计企业数量时:如果统计本监管单位则使用精确匹配
boolean isOrgCodeExactMatch = !ValidationUtil.isEmpty(RegulatoryUnitLevelEnum.getEnumByCode(r.getLevel()));
SkjsCompanyCountItemDto companyCountItemDto = new SkjsCompanyCountItemDto();
companyCountItemDto.setRegionCode(regionCode);
companyCountItemDto.setRegionName(r.getRegionName());
companyCountItemDto.setSuperviseKey(regionCode + "_" + r.getRegionName());
if (StringUtils.isNotEmpty(orgCode)) {
List<CountDto> countDtos = enterpriseInfoMapper.countByUnitTypeAndOrgCode(orgCode, regionCode);
List<CountDto> countDtos = enterpriseInfoMapper.countByUnitTypeAndOrgCode(orgCode, conditionRegionCode, isOrgCodeExactMatch);
int u1 = countDtos.stream().filter(c -> c.getKeyStr().contains(COMPANY_TYPE_USE) || c.getKeyStr().contains(COMPANY_TYPE_PERSON)).mapToInt(CountDto::getIntValue).sum();
int u3 = countDtos.stream().filter(c -> c.getKeyStr().contains(COMPANY_TYPE_MANUFACTURE)).mapToInt(CountDto::getIntValue).sum();
int u2 = countDtos.stream().filter(c -> c.getKeyStr().contains(COMPANY_TYPE_MAINTENANCE)).mapToInt(CountDto::getIntValue).sum();
......@@ -3752,12 +3769,24 @@ public class JGDPStatisticsServiceImpl {
// 多线程处理
Map<String, SkjsUserCountItemDto> userCountItemDtoMap = regionModels.parallelStream().map(r -> {
String regionCode = r.getRegionCode().toString();
String conditionRegionCode = regionCode;
String orgCode = stCommonService.getAndSetOrgCode(regionCode);
SkjsUserCountItemDto userCountItemDto = new SkjsUserCountItemDto();
userCountItemDto.setRegionCode(regionCode);
userCountItemDto.setRegionName(r.getRegionName());
userCountItemDto.setSuperviseKey(regionCode + "_" + r.getRegionName());
//按管辖机构统计企业数量时:检验检测机构直接归属省局管辖,则只有省局才统计检验检测机构数量。其他地市区县不统计
//只有按监管单位统计(r.getLeveL()为空或者为省市区县级)才需要判断是否传regionCode
if (!ValidationUtil.isEmpty(RegulatoryUnitLevelEnum.getEnumByCode(r.getLevel())) || ValidationUtil.isEmpty(r.getLevel()))
{
if (!RegulatoryUnitLevelEnum.省局.getCode().equals(r.getLevel())) {
conditionRegionCode = null;
}
}
//按管辖机构统计企业数量时:如果统计本监管单位则使用精确匹配
boolean isOrgCodeExactMatch = !ValidationUtil.isEmpty(RegulatoryUnitLevelEnum.getEnumByCode(r.getLevel()));
if (StringUtils.isNotEmpty(orgCode)) {
List<CountDto> countDtos = zlStatisticsMapper.countUserByPostAndAreaCode(orgCode, regionCode);
List<CountDto> countDtos = zlStatisticsMapper.countUserByPostAndAreaCode(orgCode, conditionRegionCode, isOrgCodeExactMatch);
// 作业人员
int zyry = countDtos.stream().filter(c -> c.getKeyStr().contains(UserPostEnum.ZYRY.getCode())).mapToInt(CountDto::getIntValue).sum();
// 检验人员
......@@ -3857,5 +3886,128 @@ public class JGDPStatisticsServiceImpl {
.reduce(BigDecimal.ZERO, BigDecimal::add).setScale(3, RoundingMode.HALF_UP).toPlainString();
}
public List<Map<String, Object>> getSuperviseTreeByLoginUnitCode(String orgCode) {
List<Map<String, Object>> result = (List<Map<String, Object>>) redisUtils.get(REGULATOR_UNIT_TREE);
return filterByOrgCode(result, orgCode);
}
public List<Map<String, Object>> filterByOrgCode(List<Map<String, Object>> nodeList, String targetOrgCode) {
List<Map<String, Object>> result = new ArrayList<>();
for (Map<String, Object> node : nodeList) {
String currentOrgCode = (String) node.get("orgCode");
if (targetOrgCode.equals(currentOrgCode)) {
// 深拷贝当前节点避免修改原数据
Map<String, Object> copiedNode = new HashMap<>(node);
result.add(copiedNode);
return result;
} else {
// 检查子节点是否存在匹配
List<Map<String, Object>> children = (List<Map<String, Object>>) node.get("children");
if (children != null && !children.isEmpty()) {
List<Map<String, Object>> filteredChildren = filterByOrgCode(children, targetOrgCode);
if (!filteredChildren.isEmpty()) {
Map<String, Object> copiedNode = new HashMap<>(filteredChildren.get(0));
result.add(copiedNode);
return result;
}
}
}
}
return result;
}
public Map<String, Object> queryBarChartDataForSkjsBySupervise(DPFilterParamDto dpFilterParamDto) {
String orgCodeP = stCommonService.getAndSetOrgCode(dpFilterParamDto);
Map<String, Object> parentModel = getSuperviseTreeByLoginUnitCode(orgCodeP).get(0);
List<Map<String, Object>> regionModels = (List<Map<String, Object>>) parentModel.get("children");
List<LegendDataDto> legendDataDtos = this.buildLegendDataListForSkjs();
// 2.按照前端约定格式返回数据
Map<String, Object> result = new HashMap<>();
//2.1 图列数据构造
result.put("legendData", legendDataDtos);
List<String> xData = new ArrayList<>();
// 2.2 Y轴数据构造 定义5个图列 再查询各自数据
List<String> oneSetYData = new ArrayList<>();
List<String> cylinderYData = new ArrayList<>();
List<String> pipelineYData = new ArrayList<>();
List<String> companyYData = new ArrayList<>();
List<String> userYData = new ArrayList<>();
// 多线程处理
Map<String, SkjsCountItemDto> countItemMap = regionModels.parallelStream().map(r -> {
String companyCode = r.get("companyCode").toString();
String orgCode = r.get("orgCode").toString();
SkjsCountItemDto countItemDto = new SkjsCountItemDto();
countItemDto.setRegionCode(companyCode);
if (!ValidationUtil.isEmpty(orgCode)) {
Map<String, Object> data = new HashMap<>();
// 查询各自统计数据作为Y轴数据
// 0. 气瓶数量统计
long cylinderNum = stCommonService.staticsCenterMapCountDataForCylinder(data, orgCode, false, false, false);
countItemDto.setCylinder(String.valueOf(cylinderNum));
// 1. 设备数量统计
long oneSetNum = stCommonService.staticsCenterMapCountDataForEquip(data, cylinderNum, orgCode, true, false, false);
countItemDto.setOneSet(String.valueOf(oneSetNum));
// 2. 压力管道长度统计
countItemDto.setPipeline(stCommonService.staticsCenterMapCountDataForPipeline(data, orgCode, true, false));
// 3. 单位数量统计。按监管单位统计,检验检测机构只挂在省局下,所以各地市及区县等监管机构不统计检验检测机构企业数量
this.staticsCompanyForSkjs(countItemDto, orgCode, null);
// 4. 人员数量统计.按监管单位统计,检验检测机构只挂在省局下,所以各地市及区县等监管机构不统计检验检测机构企业人员数量
this.staticsUserForSkjs(countItemDto, null, orgCode);
} else {
countItemDto.setDefaultValues();
}
return countItemDto;
}).collect(Collectors.toMap(SkjsCountItemDto::getRegionCode, Function.identity()));
// 排序及数据构建
regionModels.forEach(r -> {
xData.add(r.get("companyName").toString());
SkjsCountItemDto countItemDto = countItemMap.get(r.get("companyCode").toString());
oneSetYData.add(countItemDto.getOneSet());
cylinderYData.add(countItemDto.getCylinder());
pipelineYData.add(countItemDto.getPipeline());
companyYData.add(countItemDto.getCompany());
userYData.add(countItemDto.getUser());
});
result.put("oneSet", oneSetYData);
result.put("cylinder", cylinderYData);
result.put("pipeline", pipelineYData);
result.put("company", companyYData);
result.put("user", userYData);
result.put("xdata", xData);
return result;
}
public Map<String, Object> querySkjsBySuperviseDetail(DPFilterParamDto dpFilterParamDto) {
String orgCodeP = stCommonService.getAndSetOrgCode(dpFilterParamDto);
Map<String, Object> parentModel = getSuperviseTreeByLoginUnitCode(orgCodeP).get(0);
List<Map<String, Object>> childrenRegionModelList = (List<Map<String, Object>>) parentModel.get("children");
List<RegionModel> regionModels = Lists.newArrayList();
childrenRegionModelList.forEach(r -> {
RegionModel regionModel = new RegionModel();
regionModel.setRegionCode(Integer.parseInt(r.get("companyCode").toString()));
regionModel.setRegionName((String) r.get("companyName"));
regionModels.add(regionModel);
});
// 如果是省局、地市局、区县局查看,则把各对应省局、地市局、区县局数据单独添加到列表中
if (!ValidationUtil.isEmpty(RegulatoryUnitLevelEnum.getEnumByCode((String) parentModel.get("level")))) {
RegionModel regionModel = new RegionModel();
regionModel.setRegionCode(Integer.parseInt(parentModel.get("companyCode").toString()));
regionModel.setRegionName((String) parentModel.get("companyName"));
// 设置等级字段是为了区分本级监管单位在查询时是否需要精确匹配
regionModel.setLevel((String) parentModel.get("level"));
regionModels.add(regionModel);
}
if (orgCodeP == null || regionModels.isEmpty()) {
return this.getDefaultSkjsDetail();
}
Map<String, Object> result = new HashMap<>();
// 设备上线情况
result.put("equipOnLineInfo", this.getEquipOnLineInfo(regionModels));
// 企业上线情况
result.put("companyOnLineInfo", this.getCompanyOnLineInfo(regionModels));
// 人员上线情况
result.put("userOnLineInfo", this.getUserOnLineInfo(regionModels));
return result;
}
}
......@@ -537,11 +537,11 @@ public class JYJCDPStatisticsServiceImpl {
return result;
}
// 1.气瓶统计
long cylinderNum = stCommonService.staticsCenterMapCountDataForCylinder(result, orgCode,true, true);
long cylinderNum = stCommonService.staticsCenterMapCountDataForCylinder(result, orgCode,true, true, false);
// 2.8大类统计
stCommonService.staticsCenterMapCountDataForEquip(result, cylinderNum, orgCode,true,true);
stCommonService.staticsCenterMapCountDataForEquip(result, cylinderNum, orgCode,true,true, false);
// 3.压力管道统计
stCommonService.staticsCenterMapCountDataForPipeline(result, orgCode,true);
stCommonService.staticsCenterMapCountDataForPipeline(result, orgCode,true, false);
// 4.报检数量统计
this.staticsCenterMapCountDataReporting(result, dpFilterParamDto);
// 5.检验检测临期设备数数量统计
......
......@@ -212,13 +212,18 @@ public class StCommonServiceImpl {
return regionList.stream().map(RegionModel::getRegionName).collect(Collectors.toList());
}
public long staticsCenterMapCountDataForCylinder(Map<String, Object> result, String orgCode,Boolean supervisoryFlag, Boolean isMatchSupervisoryCode) {
public long staticsCenterMapCountDataForCylinder(Map<String, Object> result, String orgCode, Boolean supervisoryFlag, Boolean isMatchSupervisoryCode, Boolean isOrgBranchCodeExactMatch) {
long num = 0;
CountRequest request = new CountRequest();
request.indices("idx_biz_view_jg_all");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
// 按照管辖机构区域信息模糊查询
boolMust.must(QueryBuilders.wildcardQuery("ORG_BRANCH_CODE.keyword", QueryParser.escape(orgCode) + "*"));
if (isOrgBranchCodeExactMatch) {
// 按照管辖机构区域信息精确查询
boolMust.must(QueryBuilders.termQuery("ORG_BRANCH_CODE.keyword", QueryParser.escape(orgCode)));
} else {
// 按照管辖机构区域信息模糊查询
boolMust.must(QueryBuilders.wildcardQuery("ORG_BRANCH_CODE.keyword", QueryParser.escape(orgCode) + "*"));
}
// 设备类别精确查询气瓶
boolMust.must(QueryBuilders.termQuery("EQU_CATEGORY_CODE", EQU_CATEGORY_CYLINDER));
if(isMatchSupervisoryCode){
......@@ -245,12 +250,17 @@ public class StCommonServiceImpl {
}
public long staticsCenterMapCountDataForEquip(Map<String, Object> result, long cylinderNum, String orgCode,Boolean supervisoryFlag, Boolean isMatchSupervisoryCode) {
public long staticsCenterMapCountDataForEquip(Map<String, Object> result, long cylinderNum, String orgCode, Boolean supervisoryFlag, Boolean isMatchSupervisoryCode, Boolean isOrgBranchCodeExactMatch) {
SearchRequest request = new SearchRequest();
request.indices("idx_biz_view_jg_all");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
// 按照管辖机构区域信息模糊查询
boolMust.must(QueryBuilders.wildcardQuery("ORG_BRANCH_CODE.keyword", QueryParser.escape(orgCode) + "*"));
if (isOrgBranchCodeExactMatch) {
// 按照管辖机构区域信息精确查询
boolMust.must(QueryBuilders.termQuery("ORG_BRANCH_CODE.keyword", QueryParser.escape(orgCode)));
} else {
// 按照管辖机构区域信息模糊查询
boolMust.must(QueryBuilders.wildcardQuery("ORG_BRANCH_CODE.keyword", QueryParser.escape(orgCode) + "*"));
}
if(isMatchSupervisoryCode){
if(supervisoryFlag) {
//已赋码
......@@ -305,8 +315,8 @@ public class StCommonServiceImpl {
return itemEnum.getCode();
}
public String staticsCenterMapCountDataForPipeline(Map<String, Object> result, String orgCode,Boolean supervisoryFlag) {
String length = techParamsPipelineMapper.sumPipeLengthByOrgCode(orgCode, supervisoryFlag);
public String staticsCenterMapCountDataForPipeline(Map<String, Object> result, String orgCode, Boolean supervisoryFlag, Boolean isOrgBranchCodeExactMatch) {
String length = techParamsPipelineMapper.sumPipeLengthByOrgCode(orgCode, supervisoryFlag, isOrgBranchCodeExactMatch);
BigDecimal lengthDecimal = new BigDecimal(length);
if (lengthDecimal.compareTo(BigDecimal.ZERO) > 0) {
// 数据库的米换算成千米
......
......@@ -17,8 +17,9 @@ public interface EquipTechParamPipelineMapper extends BaseMapper<EquipTechParamP
/**
* 统计压力管道长度
*
* @param orgCode 区域code对应的管辖机构
* @param orgCode 区域code对应的管辖机构
* @param isOrgBranchCodeExactMatch 是否按机构代码精确匹配
* @return 数量
*/
String sumPipeLengthByOrgCode(@Param("orgCode") String orgCode,@Param("supervisoryFlag") Boolean supervisoryFlag);
String sumPipeLengthByOrgCode(@Param("orgCode") String orgCode, @Param("supervisoryFlag") Boolean supervisoryFlag, @Param("isOrgBranchCodeExactMatch") Boolean isOrgBranchCodeExactMatch);
}
......@@ -78,7 +78,7 @@ public interface TzBaseEnterpriseInfoMapper extends BaseMapper<TzBaseEnterpriseI
*/
TzBaseEnterpriseInfo selectBySeq(Long sequenceNbr);
List<CountDto> countByUnitTypeAndOrgCode(@Param("orgCode") String orgCode,@Param("cityCode") String cityCode);
List<CountDto> countByUnitTypeAndOrgCode(@Param("orgCode") String orgCode, @Param("cityCode") String cityCode, @Param("isOrgCodeExactMatch") Boolean isOrgCodeExactMatch);
List<CountDto> countByUnitTypeAndOrgCodeNoParam();
......
......@@ -51,6 +51,14 @@
and oi.CLAIM_STATUS = '已认领'
) a
where
p."RECORD" = a."RECORD" and a.orgBranchCode like concat(#{orgCode}, '%')
p."RECORD" = a."RECORD" and
<choose>
<when test="isOrgBranchCodeExactMatch == true">
a.orgBranchCode = #{orgCode}
</when>
<otherwise>
a.orgBranchCode like concat(#{orgCode}, '%')
</otherwise>
</choose>
</select>
</mapper>
......@@ -297,9 +297,37 @@
a.unit_type as keyStr
FROM
"tz_base_enterprise_info" a
where
((a.supervise_org_code != '50' and a.supervise_org_code LIKE CONCAT (#{orgCode}, '%')) or (a.supervise_org_code = '50' and a.office_region LIKE CONCAT ('%', #{cityCode}, '%')))
and a.is_delete = '0'
<where>
(
<choose>
<when test="cityCode != null and cityCode != ''">--按监管单位统计时,省局使用
(
<choose>
<when test="isOrgCodeExactMatch != null and isOrgCodeExactMatch != ''">
a.supervise_org_code != '50' AND a.supervise_org_code = #{orgCode}
</when>
<otherwise>
a.supervise_org_code != '50' AND a.supervise_org_code LIKE CONCAT(#{orgCode}, '%')
</otherwise>
</choose>
)
OR
(a.supervise_org_code = '50' AND a.office_region LIKE CONCAT('%', #{cityCode}, '%'))
</when>
<otherwise>--按监管单位统计时,除省局使用
<choose>
<when test="isOrgCodeExactMatch != null and isOrgCodeExactMatch != ''">
a.supervise_org_code != '50' AND a.supervise_org_code = #{orgCode}
</when>
<otherwise>
a.supervise_org_code != '50' AND a.supervise_org_code LIKE CONCAT(#{orgCode}, '%')
</otherwise>
</choose>
</otherwise>
</choose>
)
AND a.is_delete = '0'
</where>
group by a.unit_type
</select>
<select id="countByUnitTypeAndOrgCodeNoParam" resultType="com.yeejoin.amos.boot.biz.common.dto.CountDto">
......
......@@ -55,12 +55,24 @@
tzs_user_info tui,
tz_base_enterprise_info bi
WHERE
tui.unit_code = bi.use_code
tui.unit_code = bi.use_code
<if test="post != '' and post != null">
and tui.new_post LIKE concat ('%', #{post}, '%')
AND tui.new_post LIKE CONCAT('%', #{post}, '%')
</if>
and ((bi.supervise_org_code != '50' and bi.supervise_org_code LIKE CONCAT (#{orgCode}, '%')) or (bi.supervise_org_code = '50' and bi.office_region LIKE CONCAT ('%', #{regionCode}, '%')))
and tui.is_delete=false
AND (
<choose>
<when test="regionCode != null and regionCode != ''">
(bi.supervise_org_code != '50' AND bi.supervise_org_code LIKE CONCAT(#{orgCode}, '%'))
OR
(bi.supervise_org_code = '50' AND bi.office_region LIKE CONCAT('%', #{regionCode}, '%'))
</when>
<otherwise>
bi.supervise_org_code != '50' AND bi.supervise_org_code LIKE CONCAT(#{orgCode}, '%')
</otherwise>
</choose>
)
AND tui.is_delete = false
</select>
<select id="queryPermissionByUserSeq" resultType="com.yeejoin.amos.boot.module.common.api.dto.TzsUserPermissionDto">
SELECT
......
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