Commit d66d5e50 authored by 刘凡's avatar 刘凡

Merge remote-tracking branch 'origin/develop_tzs_register_to_0715' into…

Merge remote-tracking branch 'origin/develop_tzs_register_to_0715' into develop_tzs_register_to_0715
parents a8d9a5f3 0d5fca62
......@@ -30,6 +30,9 @@ public enum DPMapStatisticsItemEnum {
GAS_UNITS("充装单位 (家)", "gasUnits", ""),
OPERATORS("作业人员 (人)", "operators", ""),
DEVICE_COUNT("已纳管设备数", "deviceCount", ""),
PERSON_ISSUES_COUNT("个人问题数", "个人", ""),
COMPANY_ISSUES_COUNT("企业问题数", "企业", ""),
EQU_ISSUES_COUNT("设备数", "设备", ""),
CERTIFICATE_COUNT("登记证总量", "certificateCount", "");
private String label;
private String code;
......
......@@ -181,7 +181,7 @@ public class JgChangeRegistrationReformController extends BaseController {
if (!ValidationUtil.isEmpty(receiveCompanyCode)){
String[] codes = receiveCompanyCode.split("_");
if (!ValidationUtil.isEmpty(codes)){
dto.setReceiveCompanyCode("1".equals(transferType) ? null : codes[0]);
dto.setReceiveCompanyCode(codes[0]);
}
}
dto.setCertificateStatus("1".equals(transferType) ? "已注销" : "已登记");
......
......@@ -944,7 +944,7 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg
useInfo.setUseUnitCreditCode(registration.getNewUseUnitCreditCode());
useInfoMapper.updateById(useInfo);
}
//es中的编号信息
//修改ES中使用单位信息和使用单位代码
Map<String, Map<String, Object>> resultMap = new HashMap<>();
Map<String, Object> map1 = new HashMap<>();
map1.put("USE_UNIT_CREDIT_CODE", registration.getNewUseUnitCreditCode());
......@@ -964,6 +964,7 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg
List<String> ids = historyJson.stream().map(v -> JSON.parseObject(v.toString()).getString("sequenceNbr")).collect(Collectors.toList());
List<JgUseRegistrationManage> list = useRegistrationManageService.lambdaQuery().in(BaseEntity::getSequenceNbr, ids).list();
for (JgUseRegistrationManage registrationManage : list) {
//修改使用登记证管理使用单位地址、使用单位代码、接收机构、接收机构公司代码、办理日期、使用单位地址
registrationManage.setUseUnitName(registration.getNewUseUnitName());
registrationManage.setUseUnitCreditCode(registration.getNewUseUnitCreditCode());
registrationManage.setReceiveOrgName(registration.getReceiveOrgName());
......
......@@ -67,7 +67,7 @@ import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* 移装告知服务实现类
* 移装告知服务实现类
*
* @author system_generator
* @date 2023-12-19
......@@ -114,6 +114,12 @@ public class JgTransferNoticeServiceImpl extends BaseService<JgTransferNoticeDto
private RedissonClient redissonClient;
@Autowired
ESEquipmentCategory esEquipmentCategory;
@Autowired
JgRegistrationHistoryServiceImpl jgRegistrationHistoryService;
@Autowired
JgTransferNoticeEqServiceImpl jgTransferNoticeEqService;
@Autowired
ESElavtorRepository esElavtorRepository;
/**
* 根据sequenceNbr查询
......@@ -450,8 +456,7 @@ public class JgTransferNoticeServiceImpl extends BaseService<JgTransferNoticeDto
}
}
@Autowired
ESElavtorRepository esElavtorRepository;
/**
* 分页查询
......@@ -828,7 +833,6 @@ public class JgTransferNoticeServiceImpl extends BaseService<JgTransferNoticeDto
// 检查实际状态是否不等于期望状态
commonService.checkExpectedStatus(jgTransferNotice.getNoticeStatus());
// 执行工作流并返回组装好的工作流信息
WorkflowResultDto workflowResultDto = getWorkflowResultDto(op, opinion, jgTransferNotice);
......@@ -848,8 +852,7 @@ public class JgTransferNoticeServiceImpl extends BaseService<JgTransferNoticeDto
jgTransferNotice.setPromoter("");
jgTransferNotice.setHandleDate(new Date());
jgTransferNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_FINISHED.getCode()));
//修改设备ES设备使用场所和设备详细使用地址
Map<String, Map<String, Object>> objMap = new HashMap<>();
for (JgTransferNoticeEq eq : jgTransferNoticeEqs) {
Map<String, Object> map1 = new HashMap<>();
......@@ -966,9 +969,6 @@ public class JgTransferNoticeServiceImpl extends BaseService<JgTransferNoticeDto
}
}
@Autowired
JgTransferNoticeEqServiceImpl jgTransferNoticeEqService;
private void updateEq(JgTransferNotice jgTransferNotice) {
// 组装设备注册代码
String ym = null;
......@@ -990,9 +990,6 @@ public class JgTransferNoticeServiceImpl extends BaseService<JgTransferNoticeDto
jgTransferNoticeEqService.updateBatchById(eqList);
}
@Autowired
JgRegistrationHistoryServiceImpl jgRegistrationHistoryService;
private void saveHisDataBeforeUpdate(JgTransferNotice jgTransferNotice, List<JgTransferNoticeEq> jgTransferNoticeEqs) {
String seq = jgTransferNotice.getSequenceNbr().toString();
JSONObject json = (JSONObject) JSONObject.toJSON(jgTransferNotice);
......
......@@ -2332,7 +2332,7 @@
</w:rPr>
</w:pPr>
<#list installLicenseExpirationDateList as item1>
<#list equipList.installLicenseExpirationDateList as item1>
<w:r>
<w:rPr>
<w:rFonts w:hint="eastAsia" w:ascii="宋体" w:hAnsi="宋体" w:cs="宋体"/>
......
package com.yeejoin.amos.boot.module.statistics.api.dto;
import lombok.Data;
/**
* @author Administrator
*/
@Data
public class SecurityIndexCountItemDto {
private String regionCode;
private String regionName;
/**
* 充装检查率
*/
private String czjc;
/**
* 许可有效率
*/
String xuke;
/**
* 使用登记办理率
*/
String shiyongdengji;
/**
* 检验超期率
*/
String jianyanchaoqi;
/**
* 检验合格率
*/
String jianyanhege;
/**
* 充装检查率
*/
String czjchege;
}
......@@ -46,10 +46,10 @@ public interface AQZSDPStatisticsMapper {
/**
* 单位按照资质状态分组下的统计数量
*
* @param regionCode 区域
* @param orgCode 区域
* @return List<KeyValueDto>
*/
List<KeyValueDto> queryLicenseEfficiencyOfRegion(@Param(value = "regionCode") String regionCode);
List<KeyValueDto> queryLicenseEfficiencyOfRegion(@Param(value = "orgCode") String orgCode);
/**
* 查询单个单位的有效期信息
*
......@@ -58,8 +58,9 @@ public interface AQZSDPStatisticsMapper {
*/
KeyValueDto queryLicenseEfficiencyOneCompany(@Param(value = "appId") String appId);
Map<String, Object> getInspectionExpiredRate(@Param(value = "regionCode") String regionCode, @Param(value = "appId") String appId);
Map<String, Object> getInspectionExpiredRate(@Param(value = "orgCode") String orgCode, @Param(value = "appId") String appId);
Map<String, Object> getInspectionResultRate(@Param(value = "regionCode") String regionCode, @Param(value = "appId") String appId);
Map<String, Object> getInspectionResultRate(@Param(value = "orgCode") String orgCode, @Param(value = "appId") String appId);
List<Map<String, Object>> selectByOrg(String orgCode);
}
......@@ -13,4 +13,11 @@ import org.apache.ibatis.annotations.Param;
public interface CylinderStatisticsMapper {
Long countEnterpriseNumForCylinder(@Param("orgCode") String orgCode);
/**
* 按照管辖维度,统计充装单位使用登记证的办理率
* @param orgCode 区域对应的单位orgCode
* @return 办理率*100
*/
String queryUserRegisterCertAppPercent(@Param("orgCode") String orgCode);
}
......@@ -246,8 +246,8 @@
<where>
cu.data_sources = '陕西省内企业'
AND cu.unit_type LIKE '%充装单位%'
<if test="regionCode != null and regionCode != ''">
and cu.org_code like concat(#{regionCode}, '%')
<if test="orgCode != null and orgCode != ''">
and cu.supervise_org_code like concat(#{orgCode}, '%')
</if>
<if test="appId != null and appId != ''">
and cu.app_id = #{appId}
......@@ -264,8 +264,8 @@
<where>
cu.data_sources = '陕西省内企业'
AND cu.unit_type LIKE '%充装单位%'
<if test="regionCode != null and regionCode != ''">
and cu.org_code like concat( #{regionCode}, '%')
<if test="orgCode != null and orgCode != ''">
and cu.supervise_org_code like concat( #{orgCode}, '%')
</if>
<if test="appId != null and appId != ''">
and cu.app_id = #{appId}
......@@ -303,9 +303,21 @@
where
cu.data_sources = '陕西省内企业'
AND cu.unit_type LIKE '%充装单位%'
and cu.org_code like concat('%', #{regionCode}, '%')
and cu.supervise_org_code like concat(#{orgCode}, '%')
GROUP BY strKey
</select>
<select id="selectByOrg" resultType="java.util.Map">
SELECT COUNT
( 1 ),
source_type AS sourceType
FROM
tzs_safety_problem_tracing
WHERE
governing_body_org_code LIKE concat ( #{orgCode}, '%' )
GROUP BY
source_type
</select>
</mapper>
......@@ -10,4 +10,25 @@
unit_type LIKE'%充装单位%'
and supervise_org_code like concat(#{orgCode},'%')
</select>
<select id="queryUserRegisterCertAppPercent" resultType="java.lang.String">
select
case when s2.total= 0 then 0 else round(s1.num/s2.total * 100, 2) end as percent
from
(SELECT
count(DISTINCT(a.use_unit_credit_code)) as num
FROM
"tzs_jg_use_registration_manage" a,
privilege_company c
where
a.receive_company_code = c.company_code
and a.certificate_status='已登记'
and c.org_code like concat(#{orgCode},'%')) s1,
(SELECT
count(1) as total
FROM "tz_base_enterprise_info"
where
unit_type LIKE'%充装单位%'
and supervise_org_code like concat(#{orgCode},'%')
) s2
</select>
</mapper>
......@@ -20,7 +20,7 @@ import java.util.List;
import java.util.Map;
@RestController
@Api(tags = "大屏-安全追溯统计Api")
@Api(tags = "大屏-安全追溯及气瓶统计Api")
@RequestMapping(value = "/dp/aqzs")
public class AQZSDPStatisticsController {
......@@ -33,34 +33,31 @@ public class AQZSDPStatisticsController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "大屏-气瓶-区域安全指数")
@PostMapping(value = "/security-index")
public ResponseModel<Map<String, Object>> getSecurityIndex(@RequestBody Map<String, Object> map) throws Exception {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
public ResponseModel<Map<String, Object>> getSecurityIndex(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult bindingResult) throws Exception {
List<FieldError> fieldErrors = bindingResult.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
Map<String, Object> result = statisticsService.getSecurityIndex(regionCode.toString());
Map<String, Object> result = statisticsService.getSecurityIndex(dpFilterParamDto);
return ResponseHelper.buildResponse(result);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/earlyWarning/child", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "大屏-气瓶-区域安全指数统计")
public ResponseModel<Map<String, Object>> getChildEarlyWarning(@RequestBody Map<String, Object> map) throws Exception {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
@RequestMapping(value = "/earlyWarning/child", method = RequestMethod.POST)
public ResponseModel<Map<String, Object>> getChildEarlyWarning(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult bindingResult) throws Exception {
List<FieldError> fieldErrors = bindingResult.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
return ResponseHelper.buildResponse(statisticsService.getChildEarlyWarning(regionCode.toString()));
return ResponseHelper.buildResponse(statisticsService.getChildEarlyWarning(dpFilterParamDto));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "大屏-安全追溯-左屏-问题类型主体统计")
@PostMapping(value = "/mainBodyCount")
public ResponseModel<Map<String, Object>> mainBodyCount(@RequestBody Map<String, Object> map) throws Exception {
public ResponseModel<Map<String, Object>> mainBodyCount(@RequestBody Map<String, Object> map) {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
......@@ -73,7 +70,7 @@ public class AQZSDPStatisticsController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "大屏-安全追溯-左屏-设备问题近30天统计")
@PostMapping(value = "/equipmentCount")
public ResponseModel<Map<String, Object>> equipmentCount(@RequestBody Map<String, Object> map) throws Exception {
public ResponseModel<Map<String, Object>> equipmentCount(@RequestBody Map<String, Object> map) {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
......@@ -86,7 +83,7 @@ public class AQZSDPStatisticsController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "大屏-安全追溯-左屏-企业问题近30天统计")
@PostMapping(value = "/companyCount")
public ResponseModel<List<Map<String, Object>>> companyCount(@RequestBody Map<String, Object> map) throws Exception {
public ResponseModel<List<Map<String, Object>>> companyCount(@RequestBody Map<String, Object> map) {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
......@@ -99,7 +96,7 @@ public class AQZSDPStatisticsController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "大屏-安全追溯-左屏-人员问题近30天统计")
@PostMapping(value = "/personCount")
public ResponseModel<Map<String, Object>> personCount(@RequestBody Map<String, Object> map) throws Exception {
public ResponseModel<Map<String, Object>> personCount(@RequestBody Map<String, Object> map) {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
......@@ -113,7 +110,7 @@ public class AQZSDPStatisticsController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "大屏-安全追溯-左屏-气瓶问题近30天统计")
@PostMapping(value = "/cylinderCount")
public ResponseModel<Map<String, Object>> cylinderCount(@RequestBody Map<String, Object> map) throws Exception {
public ResponseModel<Map<String, Object>> cylinderCount(@RequestBody Map<String, Object> map) {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
......@@ -126,7 +123,7 @@ public class AQZSDPStatisticsController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "大屏-安全追溯-右屏-按月统计近12个月的问题数量趋势")
@PostMapping(value = "/issueCountByMonth")
public ResponseModel<Map<String, Object>> issueCountByMonth(@RequestBody Map<String, Object> map) throws Exception {
public ResponseModel<Map<String, Object>> issueCountByMonth(@RequestBody Map<String, Object> map) {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
......@@ -139,7 +136,7 @@ public class AQZSDPStatisticsController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "大屏-安全追溯-右屏-按月统计近30天的问题数量趋势")
@PostMapping(value = "/issueCountByDay")
public ResponseModel<Map<String, Object>> issueCountByDay(@RequestBody Map<String, Object> map) throws Exception {
public ResponseModel<Map<String, Object>> issueCountByDay(@RequestBody Map<String, Object> map) {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
......@@ -151,7 +148,7 @@ public class AQZSDPStatisticsController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "大屏-安全追溯-中屏-当前区域数据统计")
@PostMapping(value = "/issueCountByCityCode")
public ResponseModel<Map<String, Object>> issueCountByCityCode(@RequestBody Map<String, Object> map) throws Exception {
public ResponseModel<Map<String, Object>> issueCountByCityCode(@RequestBody Map<String, Object> map) {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
......@@ -177,7 +174,7 @@ public class AQZSDPStatisticsController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "大屏-安全追溯-左屏-当月问题列表(主体类型、问题类型、问题时间、操作)")
@PostMapping(value = "/issueMonthList")
public ResponseModel<List<Map<String, Object>>> issueMonthList(@RequestBody Map<String, Object> map) throws Exception {
public ResponseModel<List<Map<String, Object>>> issueMonthList(@RequestBody Map<String, Object> map) {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
......@@ -189,7 +186,7 @@ public class AQZSDPStatisticsController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "大屏-安全追溯-右屏-当年问题等级分类统计")
@PostMapping(value = "/issueProblemLevelCount")
public ResponseModel<Map<String, Object>> issueProblemLevelCount(@RequestBody Map<String, Object> map) throws Exception {
public ResponseModel<Map<String, Object>> issueProblemLevelCount(@RequestBody Map<String, Object> map) {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
......@@ -201,7 +198,7 @@ public class AQZSDPStatisticsController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "大屏-安全追溯-右屏-按问题类型排名top 10")
@PostMapping(value = "/issueCompanyTop")
public ResponseModel<List<Map<String, Object>>> issueCompanyTop(@RequestBody Map<String, Object> map) throws Exception {
public ResponseModel<List<Map<String, Object>>> issueCompanyTop(@RequestBody Map<String, Object> map) {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
......@@ -236,7 +233,7 @@ public class AQZSDPStatisticsController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "大屏-安全追溯-右屏-按问题类型排名top 10")
@PostMapping(value = "/issueCountTopByProblemType")
public ResponseModel<List<Map<String, Object>>> issueCountTopByProblemType(@RequestBody Map<String, Object> map) throws Exception {
public ResponseModel<List<Map<String, Object>>> issueCountTopByProblemType(@RequestBody Map<String, Object> map) {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
......@@ -244,4 +241,26 @@ public class AQZSDPStatisticsController {
List<Map<String, Object>> result = statisticsService.issueCountTopByProblemType(regionCode.toString());
return ResponseHelper.buildResponse(result);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏-中间地图左右两侧8大类、单位、人员数量、问题数量全局统计", notes = "大屏中间-地图左右两侧8大类、单位、人员数量、问题数量全局统计")
@PostMapping(value = "/center-map/legend")
public ResponseModel<Map<String, Object>> centerMapCountForGlobal(@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.getCenterMapCountDataForGlobal(dpFilterParamDto));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "安全追溯大屏-中间地图地市统计", notes = "安全追溯大屏中间-地图地市统计")
@PostMapping(value = "/center-map/overview")
public ResponseModel<List<Map<String, Object>>> centerMapCountForOverview(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) throws Exception {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
return ResponseHelper.buildResponse(statisticsService.getCenterMapCountDataForOverview(dpFilterParamDto));
}
}
package com.yeejoin.amos.boot.module.statistcs.biz.init;
import com.yeejoin.amos.boot.module.statistcs.biz.service.impl.AQZSDPStatisticsServiceImpl;
import com.yeejoin.amos.boot.module.statistcs.biz.service.impl.JGDPStatisticsServiceImpl;
import com.yeejoin.amos.boot.module.statistcs.biz.service.impl.StCommonServiceImpl;
import com.yeejoin.amos.component.robot.AmosRequestContext;
......@@ -16,14 +17,17 @@ public class DataInitAfterRuning implements ApplicationRunner {
private JGDPStatisticsServiceImpl jgdpStatisticsService;
private AQZSDPStatisticsServiceImpl aqzsdpStatisticsService;
private StCommonServiceImpl stCommonService;
private AmosRequestContext amosRequestContext;
public DataInitAfterRuning(JGDPStatisticsServiceImpl jgdpStatisticsService, StCommonServiceImpl stCommonService, AmosRequestContext amosRequestContext) {
public DataInitAfterRuning(JGDPStatisticsServiceImpl jgdpStatisticsService, StCommonServiceImpl stCommonService, AmosRequestContext amosRequestContext, AQZSDPStatisticsServiceImpl aqzsdpStatisticsService) {
this.jgdpStatisticsService = jgdpStatisticsService;
this.stCommonService = stCommonService;
this.amosRequestContext = amosRequestContext;
this.aqzsdpStatisticsService = aqzsdpStatisticsService;
}
@Override
......@@ -34,5 +38,6 @@ public class DataInitAfterRuning implements ApplicationRunner {
RequestContext.setToken(amosRequestContext.getToken());
jgdpStatisticsService.init();
stCommonService.init();
aqzsdpStatisticsService.init();
}
}
package com.yeejoin.amos.boot.module.statistcs.biz.service.impl;
import cn.hutool.core.date.DateUtil;
import com.yeejoin.amos.boot.biz.common.dto.CountDto;
import com.yeejoin.amos.boot.biz.common.dto.KeyValueDto;
import com.yeejoin.amos.boot.module.common.api.constant.TZSCommonConstant;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto;
import com.yeejoin.amos.boot.module.common.api.enums.IssueMainBodyEnum;
import com.yeejoin.amos.boot.module.common.api.enums.IssueTypeEnum;
import com.yeejoin.amos.boot.module.common.api.enums.ReginStepEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.DPMapStatisticsItemEnum;
import com.yeejoin.amos.boot.module.statistics.api.dto.EquipQuestionNumCountDto;
import com.yeejoin.amos.boot.module.statistics.api.dto.SecurityIndexCountItemDto;
import com.yeejoin.amos.boot.module.statistics.api.mapper.AQZSDPStatisticsMapper;
import com.yeejoin.amos.boot.module.statistics.api.mapper.CylinderStatisticsMapper;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquimentEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.ymt.api.service.ITzBaseEnterpriseInfoService;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipTechParamPipelineMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseEnterpriseInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzsUserInfoMapper;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import joptsimple.internal.Strings;
import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.core.CountRequest;
import org.elasticsearch.client.core.CountResponse;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.beans.factory.annotation.Autowired;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import javax.annotation.Resource;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
......@@ -37,8 +45,9 @@ import java.text.NumberFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
......@@ -54,18 +63,102 @@ public class AQZSDPStatisticsServiceImpl {
private final static String NO_DATA_STR = "--";
@Autowired
RestHighLevelClient restHighLevelClient;
/**
* 压力容器设备种类
*/
private final static String EQU_LIST_CYLINDER = "2000";
/**
* 气瓶设备类别
*/
private final static String EQU_CATEGORY_CYLINDER = "2300";
/**
* 单位类型-使用单位
*/
private final static String COMPANY_TYPE_USE = "使用单位";
/**
* 单位类型-安装改造维修单位
*/
private final static String COMPANY_TYPE_MAINTENANCE = "安装改造维修单位";
/**
* 单位类型-制造单位
*/
private final static String COMPANY_TYPE_MANUFACTURE = "制造单位";
/**
* 单位类型-充装单位
*/
private final static String COMPANY_TYPE_FILLING = "充装单位";
private static List<EquipmentCategoryDto> equipmentCategoryDtos;
private static List<RegionModel> regionModels = new ArrayList<>();
private RestHighLevelClient restHighLevelClient;
private static Map<String, String> regionCodeOrgCodeMap = new ConcurrentHashMap<>();
@Resource
private AQZSDPStatisticsMapper statisticsMapper;
private String getLicenseEfficiencyByRegion(String regionCode) {
List<KeyValueDto> keyValueDtos = statisticsMapper.queryLicenseEfficiencyOfRegion(regionCode);
private EquipmentCategoryMapper equipmentCategoryMapper;
private EquipTechParamPipelineMapper techParamsPipelineMapper;
private TzBaseEnterpriseInfoMapper enterpriseInfoMapper;
private TzsUserInfoMapper userInfoMapper;
private CylinderStatisticsMapper cylinderStatisticsMapper;
private StCommonServiceImpl stCommonService;
public void init() {
// 数据不变所以放到内存,提高响应时间
equipmentCategoryDtos = equipmentCategoryMapper.selectClassify();
initReginCode();
}
private void initReginCode() {
Collection<RegionModel> result = Systemctl.regionClient.queryForTree(null).getResult();
result.forEach(r -> {
regionModels.add(r);
this.loopSetChildRegin(regionModels, r.getChildren());
});
}
private void loopSetChildRegin(List<RegionModel> regionModels, Collection<RegionModel> children) {
if (children != null && children.size() > 0) {
children.forEach(c -> {
regionModels.add(c);
this.loopSetChildRegin(regionModels, c.getChildren());
});
}
}
public AQZSDPStatisticsServiceImpl(RestHighLevelClient restHighLevelClient, AQZSDPStatisticsMapper statisticsMapper, EquipmentCategoryMapper equipmentCategoryMapper, EquipTechParamPipelineMapper techParamsPipelineMapper, TzBaseEnterpriseInfoMapper enterpriseInfoMapper, TzsUserInfoMapper userInfoMapper, CylinderStatisticsMapper cylinderStatisticsMapper, StCommonServiceImpl stCommonService) {
this.restHighLevelClient = restHighLevelClient;
this.statisticsMapper = statisticsMapper;
this.equipmentCategoryMapper = equipmentCategoryMapper;
this.techParamsPipelineMapper = techParamsPipelineMapper;
this.enterpriseInfoMapper = enterpriseInfoMapper;
this.userInfoMapper = userInfoMapper;
this.cylinderStatisticsMapper = cylinderStatisticsMapper;
this.stCommonService = stCommonService;
}
private String getLicenseEfficiencyByRegion(String orgCode) {
List<KeyValueDto> keyValueDtos = statisticsMapper.queryLicenseEfficiencyOfRegion(orgCode);
int totalUnitNumber = keyValueDtos.stream().mapToInt(KeyValueDto::getIValue).sum();
int okUnitNumberNumber = keyValueDtos.stream().filter(k -> k.getStrKey().equals(LICENSE_IS_OK)).mapToInt(KeyValueDto::getIValue).sum();
if (totalUnitNumber == 0) {
......@@ -79,7 +172,6 @@ public class AQZSDPStatisticsServiceImpl {
private long searchEsCount(Boolean checkOk, Boolean resultOk, String regionCode, String appId) {
CountRequest countRequest = new CountRequest("cylinder_filling");
// countRequest.indices("cylinder_filling");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
if (checkOk) {
//匹配充装前检查和充装后检查都有数据
......@@ -118,82 +210,28 @@ public class AQZSDPStatisticsServiceImpl {
}
}
public Map<String, Object> getChildEarlyWarning(String regionCode) throws Exception {
List<RegionModel> regionModels = this.setRegionIfRootParent(regionCode);
List<String> collect = regionModels.stream().map(c -> c.getRegionCode().toString()).collect(Collectors.toList());
List<CompanyModel> companyModelList = Privilege.companyClient.queryListByCompanyCode(Strings.join(collect, ",")).getResult();
Map<String, CompanyModel> companyMap = companyModelList.stream().collect(Collectors.toMap(CompanyModel::getCompanyCode, c -> c));
Set<String> legendData = new HashSet<>();
List<String> xdata = new ArrayList<>();
public Map<String, Object> getChildEarlyWarning(DPFilterParamDto dpFilterParamDto) throws Exception {
List<RegionModel> regionModels = stCommonService.setRegionIfRootParent(dpFilterParamDto.getCityCode());
Map<String, SecurityIndexCountItemDto> regionCodeSecurityIndexMap = getSecurityIndexCountItemDtoMap(regionModels);
Set<String> legendData = getLegendForCyArea();
List<String> xuke = new ArrayList<>();
List<String> shiyongdengji = new ArrayList<>();
List<String> jianyanchaoqi = new ArrayList<>();
List<String> jianyanhege = new ArrayList<>();
List<String> czjc = new ArrayList<>();
List<String> czjchege = new ArrayList<>();
// List<String> renyuan = new ArrayList<>();
legendData.add("许可有效率");
legendData.add("使用登记办理率");
legendData.add("检验超期率");
legendData.add("检验合格率");
legendData.add("充装检查率");
legendData.add("充装检查合格率");
for (RegionModel region : regionModels) {
CompanyModel companyModel = companyMap.get(region.getRegionCode().toString());
if (ObjectUtils.isEmpty(companyModel)) {
continue;
}
// 是否有充装企业在指定区域下
Boolean isHavingUnitInRegion = true;
String orgCode = companyModel.getOrgCode();
xdata.add(region.getRegionName());
// 1.许可有效率
if (!ValidationUtil.isEmpty(companyModel)) {
String value = this.getLicenseEfficiencyByRegion(orgCode);
if (NO_DATA_STR.equals(value)) {
xuke.add("0");
} else {
xuke.add(String.format("%.4f", Double.parseDouble(value) / 100.0000));
}
}
if (!ValidationUtil.isEmpty(orgCode) && !isHavingUnitInRegion) {
shiyongdengji.add("0");
jianyanchaoqi.add("0");
jianyanhege.add("0");
shiyongdengji.add("0");
czjc.add("0");
czjchege.add("0");
continue;
}
// 2.使用登记办理率
shiyongdengji.add("1");
// 3.检验超期率
jianyanchaoqi.add(String.format("%.4f", Double.parseDouble(statisticsMapper.getInspectionExpiredRate(orgCode, null).get("expiredRate").toString()) / 100.0000));
// 4.检验合格率
jianyanhege.add(String.format("%.4f", Double.parseDouble(statisticsMapper.getInspectionResultRate(orgCode, null).get("resultRate").toString()) / 100.0000));
// 5.充装检查率
long totalAll = searchEsCount(false, false, orgCode, null);
long totalCheck = searchEsCount(true, false, orgCode, null);
long totalResult = searchEsCount(false, true, orgCode, null);
if (totalAll != 0) {
czjc.add(new DecimalFormat("#.0000").format(((double) totalCheck / totalAll)));
} else {
czjc.add("0");
}
// 6.充装检查合格率
if (totalAll != 0) {
czjchege.add(new DecimalFormat("#.0000").format(((double) totalResult / totalAll)));
} else {
czjchege.add("0");
}
}
//TODO 多线程处理后,regionCodeSecurityIndexMap顺序与regionModels的顺序不一致,需让数据和x轴的顺序保存一致
List<String> xdata = stCommonService.buildXData(regionModels);
regionModels.forEach(r -> {
SecurityIndexCountItemDto countItemDto = regionCodeSecurityIndexMap.get(r.getRegionCode().toString());
xuke.add(countItemDto.getXuke());
shiyongdengji.add(countItemDto.getShiyongdengji());
jianyanchaoqi.add(countItemDto.getJianyanchaoqi());
jianyanhege.add(countItemDto.getJianyanhege());
czjc.add(countItemDto.getCzjc());
czjchege.add(countItemDto.getCzjchege());
});
Map<String, Object> result = new HashMap<>();
result.put("xdata", xdata);
result.put("legendData", legendData);
result.put("xuke", xuke);
......@@ -202,117 +240,45 @@ public class AQZSDPStatisticsServiceImpl {
result.put("jianyanhege", jianyanhege);
result.put("czjc", czjc);
result.put("czjchege", czjchege);
return result;
}
private List<RegionModel> setRegionIfRootParent(String regionCode) throws Exception {
List<RegionModel> regionList = Systemctl.regionClient.queryByParentRegionCode(Integer.parseInt(regionCode)).getResult();
// 陕西省时需要在地图返回独立的地级市:韩城、杨凌、西咸
if (regionCode.equals(TZSCommonConstant.SHAN_XI_REGION_CODE)) {
List<RegionModel> independentRegions = ReginStepEnum.enum2RegionList("map");
regionList.addAll(independentRegions);
}
return regionList;
private Set<String> getLegendForCyArea() {
Set<String> legendData = new HashSet<>();
legendData.add("许可有效率");
legendData.add("使用登记办理率");
legendData.add("检验超期率");
legendData.add("检验合格率");
legendData.add("充装检查率");
legendData.add("充装检查合格率");
return legendData;
}
public Map<String, Object> getSecurityIndex(String regionCode) throws Exception {
List<RegionModel> regionModels = this.setRegionIfRootParent(regionCode);
List<String> collect = regionModels.stream().map(c -> c.getRegionCode().toString()).collect(Collectors.toList());
List<CompanyModel> companyModelList = Privilege.companyClient.queryListByCompanyCode(Strings.join(collect, ",")).getResult();
Map<String, CompanyModel> companyMap = companyModelList.stream().collect(Collectors.toMap(CompanyModel::getCompanyCode, c -> c));
List<String> xdata = new ArrayList<>();
List<String> xuke = new ArrayList<>();
List<String> shiyongdengji = new ArrayList<>();
List<String> jianyanchaoqi = new ArrayList<>();
List<String> jianyanhege = new ArrayList<>();
List<String> czjc = new ArrayList<>();
List<String> czjchege = new ArrayList<>();
for (RegionModel region : regionModels) {
CompanyModel companyModel = companyMap.get(region.getRegionCode().toString());
if (ObjectUtils.isEmpty(companyModel)) {
continue;
}
// 是否有充装企业在指定区域下
Boolean isHavingUnitInRegion = true;
String orgCode = companyModel.getOrgCode();
xdata.add(region.getRegionName());
// 1.许可有效率
if (!ValidationUtil.isEmpty(companyModel)) {
String value = this.getLicenseEfficiencyByRegion(orgCode);
if (NO_DATA_STR.equals(value)) {
value = "0";
xuke.add(value);
} else {
xuke.add(value);
}
}
if (!ValidationUtil.isEmpty(orgCode) && !isHavingUnitInRegion) {
shiyongdengji.add("0");
jianyanchaoqi.add("0");
jianyanhege.add("0");
shiyongdengji.add("0");
czjc.add("0");
czjchege.add("0");
continue;
}
// 2.使用登记办理率
shiyongdengji.add("100");
// 3.检验超期率
jianyanchaoqi.add(statisticsMapper.getInspectionExpiredRate(orgCode, null).get("expiredRate").toString());
// 4.检验合格率
jianyanhege.add(statisticsMapper.getInspectionResultRate(orgCode, null).get("resultRate").toString());
// 5.充装检查率
long totalAll = searchEsCount(false, false, orgCode, null);
long totalCheck = searchEsCount(true, false, orgCode, null);
long totalResult = searchEsCount(false, true, orgCode, null);
if (totalAll != 0) {
czjc.add(new DecimalFormat("#.00").format(((double) totalCheck / totalAll) * 100));
} else {
czjc.add("0");
}
// 6.充装检查合格率
if (totalAll != 0) {
czjchege.add(new DecimalFormat("#.00").format(((double) totalResult / totalAll) * 100));
} else {
czjchege.add("0");
}
}
Map<String, Object> result = new HashMap<>();
public Map<String, Object> getSecurityIndex(DPFilterParamDto dpFilterParamDto) throws Exception {
List<RegionModel> regionModels = stCommonService.setRegionIfRootParent(dpFilterParamDto.getCityCode());
Map<String, SecurityIndexCountItemDto> regionCodeSecurityIndexMap = getSecurityIndexCountItemDtoMap(regionModels);
List<Map<String, String>> data = new ArrayList<>();
// List<String> ydata = new ArrayList<>();
for (int i = 0; i < xdata.size(); i++) {
List<Map<String, String>> finalData = data;
regionCodeSecurityIndexMap.forEach((k, v) -> {
Map<String, String> item = new HashMap<>();
item.put("name", xdata.get(i));
item.put("name", v.getRegionName());
// 计算xuke的加权值
double xukeWeighted = Double.parseDouble(xuke.get(i)) * 0.10; // 10%
double xukeWeighted = Double.parseDouble(v.getXuke()) * 0.10;
// 剩余权重平均分配给四个因素,每个因素大约22.5%(但为了简化,我们这里用25%的剩余权重)
double remainingWeightPerFactor = 0.90 / 4; // 简化为每个因素25%的剩余权重
double remainingWeightPerFactor = 0.90 / 4;
// 计算其他四个因素的加权值
double jianyanchaoqiWeighted = Double.parseDouble(jianyanchaoqi.get(i)) * remainingWeightPerFactor;
double jianyanhegeWeighted = Double.parseDouble(jianyanhege.get(i)) * remainingWeightPerFactor;
double czjcWeighted = Double.parseDouble(czjc.get(i)) * remainingWeightPerFactor;
double czjchegeWeighted = Double.parseDouble(czjchege.get(i)) * remainingWeightPerFactor;
double jianyanchaoqiWeighted = Double.parseDouble(v.getJianyanchaoqi()) * remainingWeightPerFactor;
double jianyanhegeWeighted = Double.parseDouble(v.getJianyanhege()) * remainingWeightPerFactor;
double czjcWeighted = Double.parseDouble(v.getCzjc()) * remainingWeightPerFactor;
double czjchegeWeighted = Double.parseDouble(v.getCzjchege()) * remainingWeightPerFactor;
// 计算总指数
double totalIndex = xukeWeighted + jianyanchaoqiWeighted + jianyanhegeWeighted + czjcWeighted + czjchegeWeighted;
item.put("value", String.format("%.2f", totalIndex));
data.add(item);
// ydata.add(String.format("%.2f", totalIndex));
}
data = data.stream()
.filter(map -> map.containsKey("value")) // 确保每个Map都包含指定的键
finalData.add(item);
});
data = finalData.stream()
.filter(map -> map.containsKey("value"))
.sorted(Comparator.comparingDouble(map -> {
// 检查并解析值,如果失败则返回Double.MIN_VALUE(或根据需要处理)
try {
......@@ -324,22 +290,89 @@ public class AQZSDPStatisticsServiceImpl {
}
}))
.collect(Collectors.toList());
Map<String, Object> result = new HashMap<>();
List<String> name = data.stream().map(map -> map.get("name")).collect(Collectors.toList());
Collections.reverse(name);
result.put("xdata", name);
List<String> value = data.stream().map(map -> map.get("value")).collect(Collectors.toList());
Collections.reverse(value);
result.put("ydata", value);
return result;
}
private Map<String, SecurityIndexCountItemDto> getSecurityIndexCountItemDtoMap(List<RegionModel> regionModels) {
// 多线程处理后,顺序与regionModels的顺序不一致,故生成list
List<SecurityIndexCountItemDto> countItemDtoList = getSecurityIndexCountDtoList(regionModels);
return countItemDtoList.stream().collect(Collectors.toMap(SecurityIndexCountItemDto::getRegionCode, Function.identity(), (k1, k2) -> k2));
}
private List<SecurityIndexCountItemDto> getSecurityIndexCountDtoList(List<RegionModel> regionModels) {
return regionModels.parallelStream().map(r -> {
String orgCode = stCommonService.getAndSetOrgCode(r.getRegionCode().toString());
SecurityIndexCountItemDto countItemDto = new SecurityIndexCountItemDto();
countItemDto.setRegionCode(r.getRegionCode().toString());
countItemDto.setRegionName(r.getRegionName());
if (ObjectUtils.isEmpty(orgCode)) {
this.setDefaultZeroData(countItemDto);
} else {
// 1.许可有效率
String value = this.getLicenseEfficiencyByRegion(orgCode);
if (NO_DATA_STR.equals(value)) {
value = "0";
countItemDto.setXuke(value);
} else {
countItemDto.setXuke(value);
}
// 2.使用登记办理率
countItemDto.setShiyongdengji(cylinderStatisticsMapper.queryUserRegisterCertAppPercent(orgCode));
// 3.检验超期率
countItemDto.setJianyanchaoqi(statisticsMapper.getInspectionExpiredRate(orgCode, null).get("expiredRate").toString());
// 4.检验合格率
countItemDto.setJianyanhege(statisticsMapper.getInspectionResultRate(orgCode, null).get("resultRate").toString());
// 5.充装检查率
long totalAll = searchEsCount(false, false, orgCode, null);
long totalCheck = searchEsCount(true, false, orgCode, null);
long totalResult = searchEsCount(false, true, orgCode, null);
if (totalAll != 0) {
countItemDto.setCzjc(new DecimalFormat("#.00").format(((double) totalCheck / totalAll) * 100));
} else {
countItemDto.setCzjc("0");
}
// 6.充装检查合格率
if (totalAll != 0) {
countItemDto.setCzjchege(new DecimalFormat("#.00").format(((double) totalResult / totalAll) * 100));
} else {
countItemDto.setCzjchege("0");
}
}
return countItemDto;
}).collect(Collectors.toList());
}
private void setDefaultZeroData(SecurityIndexCountItemDto countItemDto) {
countItemDto.setXuke("0");
countItemDto.setShiyongdengji("0");
countItemDto.setJianyanhege("0");
countItemDto.setCzjc("0");
countItemDto.setCzjchege("0");
countItemDto.setJianyanchaoqi("0");
}
private void setDefaultZeroData(List<String> xuke, List<String> shiyongdengji, List<String> jianyanchaoqi, List<String> jianyanhege, List<String> czjc, List<String> czjchege) {
xuke.add("0");
shiyongdengji.add("0");
jianyanchaoqi.add("0");
jianyanhege.add("0");
czjc.add("0");
czjchege.add("0");
}
public Map<String, Object> mainBodyCount(String cityCode) {
Map<String, Object> resultMap = new HashMap<>();
Map<String, Object> dataMap = new HashMap<>();
String startDate = LocalDate.now().minusDays(100).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
String startDate = LocalDate.now().minusDays(29).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
List<String> mainBodyNameList = IssueMainBodyEnum.getEnumNameList();
String orgCode = getAndSetOrgCode(cityCode);
String orgCode = stCommonService.getAndSetOrgCode(cityCode);
List<Map<String, Object>> list = statisticsMapper.selectByOrgAndMainBody(orgCode, mainBodyNameList, startDate, null);
List<Object> legendDataList = new ArrayList<>();
for (int i = 0; i < 2; i++) {
......@@ -384,23 +417,13 @@ public class AQZSDPStatisticsServiceImpl {
return resultMap;
}
private String getAndSetOrgCode(String cityCode) {
String orgCode = regionCodeOrgCodeMap.get(cityCode);
if (orgCode == null) {
orgCode = statisticsMapper.getOrgCodeByCompanyCode(cityCode);
if (orgCode != null) {
regionCodeOrgCodeMap.put(cityCode, orgCode);
}
}
return orgCode;
}
public Map<String, Object> equipmentCount(String cityCode) {
Map<String, Object> resultMap = new HashMap<>();
Map<String, Object> dataMap = new HashMap<>();
List<Object> xdata = new ArrayList<>();
List<Object> ydata = new ArrayList<>();
String orgCode = getAndSetOrgCode(cityCode);
String orgCode = stCommonService.getAndSetOrgCode(cityCode);
List<String> enumNameList = IssueTypeEnum.getEnumNameListByMainBody("3");
String startDate = LocalDate.now().minusDays(29).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
List<Map<String, Object>> list = statisticsMapper.selectByOrgAndProblemType(orgCode, enumNameList, startDate, IssueMainBodyEnum.EQUIPMENT.getName(), null);
......@@ -419,7 +442,7 @@ public class AQZSDPStatisticsServiceImpl {
public List<Map<String, Object>> companyCount(String cityCode) {
List<Map<String, Object>> resultList = new ArrayList<>();
Map<String, Object> dataMap = new HashMap<>();
String orgCode = getAndSetOrgCode(cityCode);
String orgCode = stCommonService.getAndSetOrgCode(cityCode);
List<String> enumNameList = IssueTypeEnum.getEnumNameListByMainBody("2");
String startDate = LocalDate.now().minusDays(29).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
List<Map<String, Object>> list = statisticsMapper.selectByOrgAndProblemType(orgCode, enumNameList, startDate, IssueMainBodyEnum.COMPANY.getName(), null);
......@@ -451,7 +474,7 @@ public class AQZSDPStatisticsServiceImpl {
Map<String, Object> dataMap = new HashMap<>();
List<Object> xdata = new ArrayList<>();
List<Object> ydata = new ArrayList<>();
String orgCode = getAndSetOrgCode(cityCode);
String orgCode = stCommonService.getAndSetOrgCode(cityCode);
List<String> enumNameList = IssueTypeEnum.getEnumNameListByMainBody("1");
String startDate = LocalDate.now().minusDays(29).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
List<Map<String, Object>> list = statisticsMapper.selectByOrgAndProblemType(orgCode, enumNameList, startDate, IssueMainBodyEnum.PERSON.getName(), null);
......@@ -472,7 +495,7 @@ public class AQZSDPStatisticsServiceImpl {
Map<String, Object> dataMap = new HashMap<>();
List<Object> xdata = new ArrayList<>();
List<Object> ydata = new ArrayList<>();
String orgCode = getAndSetOrgCode(cityCode);
String orgCode = stCommonService.getAndSetOrgCode(cityCode);
List<String> enumNameList = IssueTypeEnum.getEnumNameListByMainBody("4");
String startDate = LocalDate.now().minusDays(29).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
List<Map<String, Object>> list = statisticsMapper.selectByOrgAndProblemType(orgCode, enumNameList, startDate, IssueMainBodyEnum.EQUIPMENT.getName(), "2300");
......@@ -503,7 +526,7 @@ public class AQZSDPStatisticsServiceImpl {
legendData.add(map);
}
resultMap.put("legendData", legendData);
String orgCode = getAndSetOrgCode(cityCode);
String orgCode = stCommonService.getAndSetOrgCode(cityCode);
int year = LocalDate.now().getYear();
List<Map<String, Object>> allIssue = statisticsMapper.getIssueCountByMonth(orgCode, String.valueOf(year), null);
List<Map<String, Object>> endIssue = statisticsMapper.getIssueCountByMonth(orgCode, String.valueOf(year), "1");
......@@ -557,7 +580,7 @@ public class AQZSDPStatisticsServiceImpl {
legendData.add(map);
}
resultMap.put("legendData", legendData);
String orgCode = getAndSetOrgCode(cityCode);
String orgCode = stCommonService.getAndSetOrgCode(cityCode);
String year = LocalDate.now().minusDays(29).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
List<Map<String, Object>> allIssue = statisticsMapper.getIssueCountByDate(orgCode, year, null);
List<Map<String, Object>> endIssue = statisticsMapper.getIssueCountByDate(orgCode, year, "1");
......@@ -597,7 +620,7 @@ public class AQZSDPStatisticsServiceImpl {
}
public Map<String, Object> issueCountByCityCode(String cityCode) {
String orgCode = getAndSetOrgCode(cityCode);
String orgCode = stCommonService.getAndSetOrgCode(cityCode);
String now = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM"));
int count = statisticsMapper.countByOrgCode(orgCode, now);
Map<String, Object> resultMap = new HashMap<>();
......@@ -607,7 +630,7 @@ public class AQZSDPStatisticsServiceImpl {
public List<Map<String, Object>> issueChildrenCityCount(String cityCode) throws Exception {
List<RegionModel> regionModels = setRegionIfRootParent(cityCode);
List<RegionModel> regionModels = stCommonService.setRegionIfRootParent(cityCode);
List<Integer> regionCodeList = regionModels.stream().map(m -> m.getRegionCode()).collect(Collectors.toList());
List<Map<String, String>> orgCodeAndCompanyCodesByCompanyCodes = statisticsMapper.getOrgCodeAndCompanyCodesByCompanyCodes(regionCodeList);
List<String> orgCodes = orgCodeAndCompanyCodesByCompanyCodes.stream().map(m -> m.get("orgCode")).collect(Collectors.toList());
......@@ -645,7 +668,7 @@ public class AQZSDPStatisticsServiceImpl {
}
public List<Map<String, Object>> issueMonthList(String cityCode) {
String orgCode = getAndSetOrgCode(cityCode);
String orgCode = stCommonService.getAndSetOrgCode(cityCode);
String time = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM"));
List<Map<String, Object>> list = statisticsMapper.issueMonthList(orgCode, time);
return list;
......@@ -653,7 +676,7 @@ public class AQZSDPStatisticsServiceImpl {
public Map<String, Object> issueProblemLevelCount(String cityCode) {
Map<String, Object> resultMap = new HashMap<>();
String orgCode = getAndSetOrgCode(cityCode);
String orgCode = stCommonService.getAndSetOrgCode(cityCode);
String time = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy"));
List<Map<String, Object>> list = statisticsMapper.issueProblemLevelCount(orgCode, time);
List<Object> xdata = new ArrayList<>();
......@@ -669,7 +692,7 @@ public class AQZSDPStatisticsServiceImpl {
public List<Map<String, Object>> issueCompanyTop(String cityCode) {
List<Map<String, Object>> resultList = new ArrayList<>();
String orgCode = getAndSetOrgCode(cityCode);
String orgCode = stCommonService.getAndSetOrgCode(cityCode);
String time = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy"));
List<Map<String, Object>> list = statisticsMapper.issueCompanyTop(orgCode, time);
for (int i = 0; i < list.size(); i++) {
......@@ -684,8 +707,8 @@ public class AQZSDPStatisticsServiceImpl {
}
public List<Map<String, Object>> issueChildrenCityCountTop(String cityCode) throws Exception {
List<RegionModel> regionModels = setRegionIfRootParent(cityCode);
List<Integer> regionCodeList = regionModels.stream().map(m -> m.getRegionCode()).collect(Collectors.toList());
List<RegionModel> regionModels = stCommonService.setRegionIfRootParent(cityCode);
List<Integer> regionCodeList = regionModels.stream().map(RegionModel::getRegionCode).collect(Collectors.toList());
List<Map<String, String>> orgCodeAndCompanyCodesByCompanyCodes = statisticsMapper.getOrgCodeAndCompanyCodesByCompanyCodes(regionCodeList);
List<String> orgCodes = orgCodeAndCompanyCodesByCompanyCodes.stream().map(m -> m.get("orgCode")).collect(Collectors.toList());
String now = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy"));
......@@ -745,11 +768,11 @@ public class AQZSDPStatisticsServiceImpl {
}
public List<Map<String, Object>> issueCountTopByProblemType(String cityCode) {
String orgCode = getAndSetOrgCode(cityCode);
String orgCode = stCommonService.getAndSetOrgCode(cityCode);
List<Map<String, Object>> allList = statisticsMapper.issueCountTopByProblemType(orgCode, null);
List<Map<String, Object>> endList = statisticsMapper.issueCountTopByProblemType(orgCode, "1");
Map<String, Object> endIssuedataMap = new HashMap<>();
endList.stream().forEach(t -> {
endList.forEach(t -> {
endIssuedataMap.put(t.get("problemTypeCode").toString(), t.get("count"));
});
List<Map<String, Object>> resultList = new ArrayList<>();
......@@ -768,7 +791,7 @@ public class AQZSDPStatisticsServiceImpl {
public List<Map<String, Object>> getEquipQuestionList(DPFilterParamDto dpFilterParamDto) {
this.setDefaultFilter(dpFilterParamDto);
String orgCode = this.getAndSetOrgCode(dpFilterParamDto.getCityCode());
String orgCode = stCommonService.getAndSetOrgCode(dpFilterParamDto.getCityCode());
if (StringUtils.isEmpty(orgCode)) {
return new ArrayList<>();
}
......@@ -831,4 +854,192 @@ public class AQZSDPStatisticsServiceImpl {
}
}
public Map<String, Object> getCenterMapCountDataForGlobal(DPFilterParamDto dpFilterParamDto) {
Map<String, Object> result = new HashMap<>();
String orgCode = stCommonService.getAndSetOrgCode(dpFilterParamDto.getCityCode());
if (StringUtils.isEmpty(orgCode)) {
return new HashMap<>();
}
// 1.气瓶数量统计
long cylinderNum = this.staticsCenterMapCountDataForCylinder(result, orgCode);
//1.8大类设备数量统计,压力容器里包括气瓶所以需要特殊处理,在统计压力容器时去掉气瓶的数量
this.staticsCenterMapCountDataForEquip(result, cylinderNum, orgCode);
//2.压力管道长度统计
this.staticsCenterMapCountDataForPipeline(result, orgCode);
//3.单位数量统计
this.staticsCenterMapCountDataForCompany(result, orgCode);
//4.人员数量统计
this.staticsCenterMapCountDataForPerson(result, dpFilterParamDto, orgCode);
//5.问题数统计
this.staticsCenterMapCountDataForIssue(result, orgCode);
return result;
}
private void staticsCenterMapCountDataForIssue(Map<String, Object> result, String orgCode) {
List<Map<String, Object>> list = statisticsMapper.selectByOrg(orgCode);
Map<String, Object> dataMap = new HashMap<>();
AtomicReference<Long> issueCount = new AtomicReference<>(0L);
list.stream().forEach(t -> {
dataMap.put(t.get("sourceType").toString(), t.get("count"));
issueCount.updateAndGet(v -> v + Long.parseLong(t.get("count").toString()));
});
result.put("issueCount", issueCount.get());
result.put("deviceIssueCount", dataMap.getOrDefault(DPMapStatisticsItemEnum.EQU_ISSUES_COUNT, 0L));
result.put("companyIssueCount", dataMap.getOrDefault(DPMapStatisticsItemEnum.COMPANY_ISSUES_COUNT, 0L));
result.put("personIssueCount", dataMap.getOrDefault(DPMapStatisticsItemEnum.PERSON_ISSUES_COUNT, 0L));
}
private long staticsCenterMapCountDataForCylinder(Map<String, Object> result, String orgCode) {
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) + "*"));
// 设备类别精确查询气瓶
boolMust.must(QueryBuilders.termsQuery("EQU_CATEGORY_CODE", EQU_CATEGORY_CYLINDER));
// 且在用状态设备
boolMust.must(QueryBuilders.termQuery("EQU_STATE", EquimentEnum.ZAIYONG.getCode()));
request.query(boolMust);
try {
CountResponse response = restHighLevelClient.count(request, RequestOptions.DEFAULT);
num = response.getCount();
} catch (IOException e) {
throw new RuntimeException(e);
}
result.put(DPMapStatisticsItemEnum.GAS.getCode(), num);
return num;
}
private void staticsCenterMapCountDataForEquip(Map<String, Object> result, long cylinderNum, String orgCode) {
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) + "*"));
// 且在用状态设备
boolMust.must(QueryBuilders.termQuery("EQU_STATE", EquimentEnum.ZAIYONG.getCode()));
SearchSourceBuilder builder = new SearchSourceBuilder();
builder.query(boolMust);
TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms("count_by_equ_list_code").field("EQU_LIST_CODE");
builder.aggregation(aggregationBuilder);
request.source(builder);
try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
Terms terms = response.getAggregations().get("count_by_equ_list_code");
Map<String, Long> countMap = new HashMap<>();
for (Terms.Bucket bucket : terms.getBuckets()) {
// 压力容器里包括气瓶所以需要特殊处理,在统计压力容器时去掉气瓶的数量
if (bucket.getKeyAsString().equals(EQU_LIST_CYLINDER)) {
countMap.put(bucket.getKeyAsString(), bucket.getDocCount() - cylinderNum);
} else {
countMap.put(bucket.getKeyAsString(), bucket.getDocCount());
}
}
// 按照8大类枚举,进行加工。目的:固定八大类防止没统计数据导致缺少分类、将设备种类的code换成前端定义的key
equipmentCategoryDtos.forEach(c -> {
result.put(this.castCategoryCode2WebCode(c.getCode()), countMap.getOrDefault(c.getCode(), 0L));
});
result.put(DPMapStatisticsItemEnum.TOTAL.getCode(), countMap.values().stream().mapToLong(e -> e).sum() + cylinderNum);
} catch (IOException e) {
throw new RuntimeException(e);
}
result.remove(DPMapStatisticsItemEnum.PRESSURE_PIPELINES.getCategory());
}
private String castCategoryCode2WebCode(String category) {
DPMapStatisticsItemEnum itemEnum = DPMapStatisticsItemEnum.getInstanceByCategory(category);
return itemEnum.getCode();
}
private void staticsCenterMapCountDataForPipeline(Map<String, Object> result, String orgCode) {
String length = techParamsPipelineMapper.sumPipeLengthByOrgCode(orgCode);
BigDecimal lengthDecimal = new BigDecimal(length);
if (lengthDecimal.compareTo(BigDecimal.ZERO) > 0) {
length = lengthDecimal.divide(new BigDecimal("1000"), 3, RoundingMode.HALF_UP).toPlainString();
}
result.put(DPMapStatisticsItemEnum.PRESSURE_PIPELINES.getCode(), length);
}
private void staticsCenterMapCountDataForCompany(Map<String, Object> result, String orgCode) {
if (orgCode == null) {
setDefaultCompanyCountData(result);
return;
}
List<CountDto> countDtos = enterpriseInfoMapper.countByUnitTypeAndOrgCode(orgCode);
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());
result.put(DPMapStatisticsItemEnum.GAS_UNITS.getCode(), countDtos.stream().filter(c -> c.getKeyStr().contains(COMPANY_TYPE_FILLING)).mapToInt(CountDto::getIntValue).sum());
}
private void setDefaultCompanyCountData(Map<String, Object> m) {
m.put(DPMapStatisticsItemEnum.USERS_UNITS.getCode(), 0);
m.put(DPMapStatisticsItemEnum.CONSTRUCTION_UNITS.getCode(), 0);
m.put(DPMapStatisticsItemEnum.MANUFACTURING_UNITS.getCode(), 0);
m.put(DPMapStatisticsItemEnum.GAS_UNITS.getCode(), 0);
}
private void staticsCenterMapCountDataForPerson(Map<String, Object> result, DPFilterParamDto dpFilterParamDto, String orgCode) {
if (orgCode == null) {
result.put(DPMapStatisticsItemEnum.OPERATORS.getCode(), 0);
return;
}
Long num = userInfoMapper.countUserByPostAndAreaCode(orgCode, "6552", dpFilterParamDto.getCityCode());
result.put(DPMapStatisticsItemEnum.OPERATORS.getCode(), num);
}
public List<Map<String, Object>> getCenterMapCountDataForOverview(DPFilterParamDto dpFilterParamDto) throws Exception {
List<RegionModel> regionModels = stCommonService.setRegionIfRootParent(dpFilterParamDto.getCityCode());
List<Map<String, Object>> result = regionModels.parallelStream().map(r -> {
DPFilterParamDto filterParamDto = new DPFilterParamDto();
filterParamDto.setCityCode(r.getRegionCode().toString());
Map<String, Object> itemResult = getCenterMapOverviewData(filterParamDto);
itemResult.put("regionCode", r.getRegionCode());
itemResult.put("regionName", r.getRegionName());
return itemResult;
}).collect(Collectors.toList());
this.setCompanyDataBatch(result);
return result;
}
private void setCompanyDataBatch(List<Map<String, Object>> result) {
List<CountDto> countDtos = enterpriseInfoMapper.countByUnitTypeAndOrgCodeNoParam();
result.forEach(m -> {
String cityCode = m.get("regionCode").toString();
String orgCode = stCommonService.getAndSetOrgCode(cityCode);
if (orgCode != null) {
m.put(DPMapStatisticsItemEnum.USERS_UNITS.getCode(), countDtos.stream().filter(c -> c.getKeyStr().contains(COMPANY_TYPE_USE) && c.getLabel().contains(orgCode)).mapToInt(CountDto::getIntValue).sum());
m.put(DPMapStatisticsItemEnum.CONSTRUCTION_UNITS.getCode(), countDtos.stream().filter(c -> c.getKeyStr().contains(COMPANY_TYPE_MAINTENANCE) && c.getLabel().contains(orgCode)).mapToInt(CountDto::getIntValue).sum());
m.put(DPMapStatisticsItemEnum.MANUFACTURING_UNITS.getCode(), countDtos.stream().filter(c -> c.getKeyStr().contains(COMPANY_TYPE_MANUFACTURE) && c.getLabel().contains(orgCode)).mapToInt(CountDto::getIntValue).sum());
m.put(DPMapStatisticsItemEnum.GAS_UNITS.getCode(), countDtos.stream().filter(c -> c.getKeyStr().contains(COMPANY_TYPE_FILLING) && c.getLabel().contains(orgCode)).mapToInt(CountDto::getIntValue).sum());
} else {
setDefaultCompanyCountData(m);
}
});
}
private Map<String, Object> getCenterMapOverviewData(DPFilterParamDto dpFilterParamDto) {
Map<String, Object> result = new HashMap<>();
String orgCode = stCommonService.getAndSetOrgCode(dpFilterParamDto.getCityCode());
if (StringUtils.isEmpty(orgCode)) {
return new HashMap<>();
}
// 0. 气瓶数量统计
long cylinderNum = this.staticsCenterMapCountDataForCylinder(result, orgCode);
// 1. 8大类设备数量统计,压力容器里包括气瓶所以需要特殊处理,在统计压力容器时去掉气瓶的数量
this.staticsCenterMapCountDataForEquip(result, cylinderNum, orgCode);
// 2. 压力管道长度统计
this.staticsCenterMapCountDataForPipeline(result, orgCode);
// 3.单位数量统计
this.staticsCenterMapCountDataForCompany(result, orgCode);
// 4. 人员数量统计
this.staticsCenterMapCountDataForPerson(result, dpFilterParamDto, orgCode);
// 5.问题统计
this.staticsCenterMapCountDataForIssue(result, orgCode);
return result;
}
}
\ No newline at end of file
......@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
/**
* @author Administrator
......@@ -78,4 +79,9 @@ public class StCommonServiceImpl {
}
return regionList;
}
public List<String> buildXData(List<RegionModel> regionList) {
return regionList.stream().map(RegionModel::getRegionName).collect(Collectors.toList());
}
}
......@@ -2,8 +2,9 @@ package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.EquipTechParamPipeline;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface EquipTechParamPipelineMapper extends BaseMapper<EquipTechParamPipeline> {
/**
* 在用的最新需求整理的技术参数--需求未出
......
......@@ -7,6 +7,7 @@ import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.UseUnitCreditCodeCategoryDto;
import com.yeejoin.amos.boot.module.ymt.api.vo.EquipExportVo;
import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
......@@ -19,6 +20,7 @@ import java.util.Map;
* @author system_generator
* @date 2021-10-20
*/
@Mapper
public interface EquipmentCategoryMapper extends BaseMapper<EquipmentCategory> {
@Select("select * from tz_equipment_category where code in('1000','2000','3000','4000','5000','6000','8000','9000')")
......
......@@ -7,6 +7,7 @@ import com.yeejoin.amos.boot.biz.common.dto.CountDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquEnterDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.TzBaseEnterpriseInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.TzBaseEnterpriseInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -17,6 +18,7 @@ import java.util.List;
* @author duanwei
* @date 2022-08-10
*/
@Mapper
public interface TzBaseEnterpriseInfoMapper extends BaseMapper<TzBaseEnterpriseInfo> {
/**
......
......@@ -4,8 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.ymt.api.dto.TzsUserInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.TzsUserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface TzsUserInfoMapper extends BaseMapper<TzsUserInfo> {
Page<TzsUserInfoDto> selectPageMessage(@Param("page") Page<TzsUserInfoDto> page, @Param("dto") TzsUserInfoDto dto);
......
......@@ -155,7 +155,7 @@
<if test="orgCodes != null and orgCodes.size > 0">
AND
<foreach collection="orgCodes" open="(" item="orgCode" close=")" separator=" or ">
(u.org_code like concat(#{orgCode}, '%') )
(u.supervise_org_code like concat(#{orgCode}, '%') )
</foreach>
</if>
</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