Commit 9de456eb authored by tianbo's avatar tianbo

Merge branch 'develop_tzs_bugfix' into develop_tzs_register

parents c9a4efb2 84128f8e
......@@ -17,7 +17,7 @@ public enum SafetyProblemTypeEnum {
JYBJ("21", "检验报检", "设备报检", "safetyProblemTracing/jy/bj", null),
WBCQ("1", "维保超期", "设备维保超期", "safetyProblemTracing/wb/cq", "outOfMaintenanceRecords"),
WBBA("11", "维保合同备案", "设备维保合同备案", "safetyProblemTracing/wb/ba", null),
ZZCQ("3", "资质超期", "企业资质超期", "safetyProblemTracing/zz/cq", null);
XKCQ("3", "许可超期", "企业许可超期", "safetyProblemTracing/xk/cq", null);
private final String code;
......
......@@ -13,6 +13,7 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 装备分类 Mapper 接口
......@@ -141,6 +142,11 @@ public interface CommonMapper extends BaseMapper<EquipmentCategory> {
List<Map<String, Object>> queryOutOfInspectionRecord();
/**
* 查询许可超期的企业
* */
List<Map<String, Object>> queryOutOfQualificationRecord();
/**
* 大屏业务全过程统计已经完成的单据
*
* @param orgCode 行政区划对应公司的orgCode
......@@ -223,5 +229,6 @@ public interface CommonMapper extends BaseMapper<EquipmentCategory> {
List<Map<String, String>> VINAccountUniqueWithVehGasCyl(@Param("VIN") String VIN,
@Param("record") String record);
void updateEnterpriseSafetyStatus(@Param("useUnitCodeList") Set<String> useUnitCodeList);
}
......@@ -28,4 +28,6 @@ public interface SafetyProblemTracingMapper extends BaseMapper<SafetyProblemTrac
List<String> getBusinessType(@Param("sourceTypeCode") String sourceTypeCode, @Param("orgCode") String orgCode);
List<Map<String, Object>> getBusinessCount(@Param("sourceTypeCode") String sourceTypeCode, @Param("orgCode") String orgCode);
Long countByTypeListAndOrgCode(@Param("typeList") List<String> typeList, @Param("orgCode") String orgCode, @Param("mainBody") String mainBody);
}
......@@ -2550,4 +2550,37 @@
</where>
</select>
<select id="queryOutOfQualificationRecord" resultType="java.util.Map">
SELECT
ei.use_unit_code useUnitCode,
ei.use_unit useUnit,
ei.unit_type unitType,
ei.supervise_org_code superviseOrgCode,
ei.supervise_org_name superviseOrgName,
ul.sequence_nbr licenceSeq,
ul.cert_no certNo,
ul.expiry_date expiryDate,
ul.item_code itemCode,
ul.item_code_name itemName,
ul.sub_item_code subItemCode,
ul.sub_item_name subItemName
FROM
tz_base_unit_licence ul
LEFT JOIN tz_base_enterprise_info ei ON ul.unit_code = ei.use_unit_code
WHERE
ei.use_unit_code IS NOT NULL
AND ul.is_delete = 0
AND ul.expiry_date <![CDATA[<]]> to_char( now( ), 'YYYY-MM-DD' )
</select>
<update id="updateEnterpriseSafetyStatus">
update tz_base_enterprise_info
set status = '1'
where use_unit_code in
<foreach item="item" index="index" collection="useUnitCodeList"
open="(" separator="," close=")">
#{item}
</foreach>
</update>
</mapper>
......@@ -179,4 +179,24 @@
problem_type,
problem_status_code;
</select>
<select id="countByTypeListAndOrgCode" resultType="java.lang.Long">
SELECT
COUNT(1)
FROM
tzs_safety_problem_tracing
WHERE
is_delete = '0'
<if test="orgCode != null and orgCode != ''">
and governing_body_org_code like CONCAT(#{orgCode}, '%')
</if>
<if test="typeList != null and typeList.size > 0">
and problem_type in
<foreach collection="typeList" item="type" open="(" separator="," close=")">
#{type}
</foreach>
</if>
<if test="mainBody != null and mainBody != ''">
and source_type_code = #{mainBody}
</if>
</select>
</mapper>
......@@ -28,8 +28,8 @@ public class SafetyProblemEventHandlerFactory {
return new JYCQEventHandler(safetyProblemTracingService);
} else if (topic.startsWith(SafetyProblemTypeEnum.JYBJ.getTopic())) {
return new JYBJEventHandler(safetyProblemTracingService, idxBizJgOtherInfoService, esEquipmentCategory);
} else if (topic.startsWith(SafetyProblemTypeEnum.ZZCQ.getTopic())) {
return new ZZCQEventHandler();
} else if (topic.startsWith(SafetyProblemTypeEnum.XKCQ.getTopic())) {
return new XKCQEventHandler(safetyProblemTracingService);
} else {
// 其他策略类的创建
throw new IllegalArgumentException("Unsupported topic: " + topic);
......
package com.yeejoin.amos.boot.module.jg.biz.handler;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.api.enums.SafetyProblemTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.event.SafetyProblemEvent;
import com.yeejoin.amos.boot.module.jg.api.event.handler.SafetyProblemEventHandler;
import com.yeejoin.amos.boot.module.jg.biz.listener.SafetyProblemTopicMessage;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.SafetyProblemTracingServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* ZZCQEventHandler 类实现了 SafetyProblemEventHandler 接口,
* XKCQEventHandler 类实现了 SafetyProblemEventHandler 接口,
* 用于处理企业资质超期安全问题事件。
*/
@Component
public class ZZCQEventHandler implements SafetyProblemEventHandler {
public class XKCQEventHandler implements SafetyProblemEventHandler {
SafetyProblemTracingServiceImpl safetyProblemTracingService;
@Autowired
public XKCQEventHandler(SafetyProblemTracingServiceImpl safetyProblemTracingService) {
this.safetyProblemTracingService = safetyProblemTracingService;
}
/**
* 处理安全问题事件。
......@@ -21,10 +33,12 @@ public class ZZCQEventHandler implements SafetyProblemEventHandler {
@Override
public void handle(SafetyProblemEvent event) {
// 此处为处理安全问题事件的逻辑代码
generateProblem(JSONObject.parseObject(event.getMessage().toString()));
JSONArray jsonArray = JSONObject.parseArray(event.getMessage().toString());
generateProblem(jsonArray);
}
private void generateProblem(JSONObject jsonObject) {
private void generateProblem(JSONArray jsonArray) {
SafetyProblemTopicMessage.generateUnitProblem(jsonArray, SafetyProblemTypeEnum.XKCQ, safetyProblemTracingService);
}
}
......@@ -150,6 +150,42 @@ public class SafetyProblemTopicMessage extends EmqxListener {
.eq("problem_status_code", SafetyProblemStatusEnum.UNHANDLED.getCode()));}
}
public static void generateUnitProblem(JSONArray jsonArray, SafetyProblemTypeEnum problemTypeEnum, SafetyProblemTracingServiceImpl safetyProblemTracingService) {
if (jsonArray == null || problemTypeEnum == null) {
throw new IllegalArgumentException("jsonObject and problemTypeEnum must not be null.");
}
if (!ValidationUtil.isEmpty(jsonArray)) {
List<SafetyProblemTracing> safetyProblemTracingList = jsonArray.stream().map(item -> {
if (!(item instanceof JSONObject)) {
throw new IllegalArgumentException("item is not a JSONObject.");
}
JSONObject json = (JSONObject) item;
SafetyProblemTracing safetyProblemTracing = new SafetyProblemTracing();
safetyProblemTracing.setProblemType(problemTypeEnum.getName());
safetyProblemTracing.setProblemTypeCode(problemTypeEnum.getCode());
safetyProblemTracing.setProblemDesc(problemTypeEnum.getDesc() + "-" + json.getOrDefault("itemName", "") + "-" + json.getOrDefault("subItemName", ""));
safetyProblemTracing.setSourceType(SafetyProblemSourceTypeEnum.UNIT.getName());
safetyProblemTracing.setSourceTypeCode(SafetyProblemSourceTypeEnum.UNIT.getCode());
safetyProblemTracing.setSourceId(json.getOrDefault("licenceSeq", "").toString());
safetyProblemTracing.setProblemTime(new Date());
safetyProblemTracing.setPrincipalUnit(json.getOrDefault("useUnit", "").toString());
safetyProblemTracing.setPrincipalUnitCode(json.getOrDefault("useUnitCode", "").toString());
safetyProblemTracing.setPrincipalUnitType(json.getOrDefault("unitType", "").toString());
safetyProblemTracing.setGoverningBody(json.getOrDefault("superviseOrgName", "").toString());
safetyProblemTracing.setGoverningBodyCode(json.getOrDefault("useUnitCode", "").toString());
safetyProblemTracing.setGoverningBodyOrgCode(json.getOrDefault("superviseOrgCode", "").toString());
safetyProblemTracing.setCreateDate(new Date());
safetyProblemTracing.setProblemStatus(SafetyProblemStatusEnum.UNHANDLED.getName());
safetyProblemTracing.setProblemStatusCode(SafetyProblemStatusEnum.UNHANDLED.getCode());
return safetyProblemTracing;
}).collect(Collectors.toList());
safetyProblemTracingService.saveOrUpdateBatchByColumns(safetyProblemTracingList,
safetyProblemTracing -> new QueryWrapper<>()
.eq("problem_type_code", safetyProblemTracing.getProblemTypeCode())
.eq("source_id", safetyProblemTracing.getSourceId())
.eq("problem_status_code", SafetyProblemStatusEnum.UNHANDLED.getCode()));}
}
public String buildTopic(String topic) {
String topicPrefix = "$share/" + applicationName;
return String.format("%s/%s", topicPrefix, topic);
......
......@@ -10,8 +10,8 @@ import com.yeejoin.amos.boot.module.jg.api.entity.SafetyProblemTracing;
import com.yeejoin.amos.boot.module.jg.api.enums.SafetyProblemStatusEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.SafetyProblemTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.CommonMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.SafetyProblemTracingMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgOtherInfo;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseEnterpriseInfoMapper;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.slf4j.Logger;
......@@ -20,10 +20,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 安全追溯问题生成服务实现类
......@@ -50,11 +52,15 @@ public class SafetyProblemTracingGenServiceImpl{
@Autowired
private SafetyProblemTracingServiceImpl safetyProblemTracingService;
@Autowired
TzBaseEnterpriseInfoMapper baseEnterpriseInfoMapper;
@Scheduled(cron = "0 0 1 * * ?")
@SchedulerLock(name = "executeSafetyProblemCheck", lockAtMostFor = "PT5H", lockAtLeastFor = "PT10M")
public void executeSafetyProblemCheck() {
executeMaintenanceCheck();
executeInspectionCheck();
executeEnterpriseQualificationCheck();
}
public void executeInspectionCheck() {
......@@ -73,6 +79,14 @@ public class SafetyProblemTracingGenServiceImpl{
logger.info("维保超期检查结束");
}
public void executeEnterpriseQualificationCheck() {
logger.info("开始企业许可超期检查");
// 查询当天许可超期的企业许可数据
List<Map<String, Object>> outOfQualificationRecords = commonMapper.queryOutOfQualificationRecord();
updateEnterpriseAndSendMessage(outOfQualificationRecords);
logger.info("企业许可超期检查结束");
}
public void update3MaintenanceCheck() {
logger.info("开始修正数据");
List<String> oldAllRecords = idxBizJgOtherInfoService.getBaseMapper()
......@@ -122,6 +136,25 @@ public class SafetyProblemTracingGenServiceImpl{
esEquipmentCategory.saveAll(esEquipmentCategoryDto);
// JSONObject jsonObject = new JSONObject();
// jsonObject.put(safetyProblemTypeEnum.getMsgKey(), mapList);
sendSafetyProblemMessage(mapList, safetyProblemTypeEnum);
}
private void updateEnterpriseAndSendMessage(List<Map<String, Object>> mapList) {
Set<String> outOfUnitLicenseList = mapList.stream().map(m -> m.get("useUnitCode").toString()).collect(Collectors.toSet());
if (ValidationUtil.isEmpty(outOfUnitLicenseList)) {
return;
}
// 更新企业问题状态为未处理(异常)-多个许可超期归并一个企业问题
commonMapper.updateEnterpriseSafetyStatus(outOfUnitLicenseList);
sendSafetyProblemMessage(mapList, SafetyProblemTypeEnum.XKCQ);
}
/**
* 发送安全问题
* @param mapList
* @param safetyProblemTypeEnum
*/
private void sendSafetyProblemMessage(List<Map<String, Object>> mapList, SafetyProblemTypeEnum safetyProblemTypeEnum) {
JSONArray jsonArray = JSON.parseArray(JSON.toJSONString(mapList));
try {
emqKeeper.getMqttClient().publish(safetyProblemTypeEnum.getTopic(), jsonArray.toString().getBytes(StandardCharsets.UTF_8), 2, false);
......
......@@ -22,6 +22,7 @@ import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamForDetailDto;
import com.yeejoin.amos.boot.module.common.api.dto.FormValue;
import com.yeejoin.amos.boot.module.common.api.dto.LegendDataDto;
import com.yeejoin.amos.boot.module.common.api.enums.BusinessTypeEnum;
import com.yeejoin.amos.boot.module.common.api.enums.IssueMainBodyEnum;
import com.yeejoin.amos.boot.module.common.api.enums.JgBusinessTypeEnum;
import com.yeejoin.amos.boot.module.common.api.enums.NoticBusinessTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.dto.EquipBizCountDto;
......@@ -640,11 +641,21 @@ public class JGDPStatisticsServiceImpl {
private CountDto getRedStatusEquip(DPFilterParamDto dpFilterParamDto) {
CountDto countDto = new CountDto();
countDto.setLongValue(this.staticsCenterMapCountDateOverdue(dpFilterParamDto));
countDto.setLongValue(this.staticsCenterMapCountDateOverdueNew(dpFilterParamDto));
countDto.setLabel("超期未检");
return countDto;
}
private Long staticsCenterMapCountDateOverdueNew(DPFilterParamDto dpFilterParamDto) {
Long num = 0L;
String orgCode = stCommonService.getAndSetOrgCode(dpFilterParamDto.getCityCode());
List<String> typeList = new ArrayList<>();
typeList.add("维保超期");
typeList.add("检验超期");
num = safetyProblemTracingMapper.countByTypeListAndOrgCode(typeList,orgCode, IssueMainBodyEnum.EQUIPMENT.getCode());
return num;
}
private Map<String, Map<String, CountDto>> getAllDataMap(DPFilterParamDto dpFilterParamDto) {
Map<String, Map<String, CountDto>> countMap = new HashMap<>();
countMap.put(FourColorCountItemEnum.EQUIP.getKey(), this.countEquipNum(dpFilterParamDto));
......@@ -757,11 +768,20 @@ public class JGDPStatisticsServiceImpl {
private CountDto getRedStatusCompany(DPFilterParamDto dpFilterParamDto) {
CountDto countDto = new CountDto();
countDto.setLongValue(this.countCompanyForCertDateTimeOut(dpFilterParamDto));
countDto.setLongValue(this.countCompanyForCertDateTimeOutNew(dpFilterParamDto));
countDto.setLabel("许可超期");
return countDto;
}
private Long countCompanyForCertDateTimeOutNew(DPFilterParamDto dpFilterParamDto) {
Long num = 0L;
String orgCode = stCommonService.getAndSetOrgCode(dpFilterParamDto.getCityCode());
List<String> typeList = new ArrayList<>();
typeList.add("许可超期");
num = safetyProblemTracingMapper.countByTypeListAndOrgCode(typeList,orgCode, IssueMainBodyEnum.COMPANY.getCode());
return num;
}
private CountDto getYellowStatusCompany(DPFilterParamDto dpFilterParamDto) {
CountDto countDto = new CountDto();
countDto.setLongValue(this.countCompanyForCertDateTemporary(dpFilterParamDto));
......@@ -821,10 +841,14 @@ public class JGDPStatisticsServiceImpl {
}
private CountDto getRedStatusUser(DPFilterParamDto dpFilterParamDto) {
// TODO 需求不明确
CountDto countDto = new CountDto();
countDto.setLongValue(0L);
countDto.setLabel("许可超期");
countDto.setLabel("资质超期");
Long num = 0L;
String orgCode = stCommonService.getAndSetOrgCode(dpFilterParamDto.getCityCode());
List<String> typeList = new ArrayList<>();
typeList.add("资质超期");
num = safetyProblemTracingMapper.countByTypeListAndOrgCode(typeList,orgCode, IssueMainBodyEnum.PERSON.getCode());
countDto.setLongValue(num);
return countDto;
}
......
......@@ -679,8 +679,8 @@ public class ZLDPStatisticsServiceImpl {
JSONObject jsonObject9 = new JSONObject();
jsonObject9.put("key", "csjsynx");
jsonObject9.put("value", orgCode == null ? 0L: this.getQuestionNumber("超设计使用年限",params, orgCode));
jsonObject9.put("name", "超设计使用年限");
jsonObject9.put("value", orgCode == null ? 0L: this.getQuestionNumber("超设计年限",params, orgCode));
jsonObject9.put("name", "超设计年限");
JSONObject jsonObject10 = new JSONObject();
jsonObject10.put("key", "zzlq");
......@@ -689,9 +689,14 @@ public class ZLDPStatisticsServiceImpl {
JSONObject jsonObject11 = new JSONObject();
jsonObject11.put("key", "zzcq");
jsonObject11.put("value", orgCode == null ? 0L: stCommonService.getRedStatusCompany(params).getLongValue());
jsonObject11.put("value", orgCode == null ? 0L: this.getQuestionNumber("许可超期",params, orgCode));
jsonObject11.put("name", "许可超期");
JSONObject jsonObject12 = new JSONObject();
jsonObject12.put("key", "jyzzcq");
jsonObject12.put("value", orgCode == null ? 0L: this.getQuestionNumber("资质超期",params, orgCode));
jsonObject12.put("name", "资质超期");
jsonArray.add(jsonObject0);
jsonArray.add(jsonObject1);
jsonArray.add(jsonObject2);
......@@ -704,6 +709,7 @@ public class ZLDPStatisticsServiceImpl {
jsonArray.add(jsonObject9);
jsonArray.add(jsonObject10);
jsonArray.add(jsonObject11);
jsonArray.add(jsonObject12);
}
return jsonArray;
......
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