Commit b4a4c845 authored by limei's avatar limei

Merge branch 'develop_dl_plan6' of http://39.98.45.134:8090/moa/amos-boot-biz into develop_dl_plan6

# Conflicts: # amos-boot-system-tdc/amos-boot-module-tdc-api/src/main/java/com/yeejoin/amos/boot/module/tdc/api/entity/CheckResult.java # amos-boot-system-tdc/amos-boot-module-tdc-biz/src/main/java/com/yeejoin/amos/boot/module/tdc/biz/service/impl/CheckModelImpl.java
parents c946c006 5c1aa910
package com.yeejoin.equipmanage.common.entity.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author keyong
* @title: IdxBizDefectVo
* <pre>
* @description: TODO
* </pre>
* @date 2022/9/27 18:44
*/
@Data
public class IdxBizDefectVo {
private String id;
@ApiModelProperty(value = "缺陷等级1-一般 2-严重 3-危急")
private Integer defectLevel;
@ApiModelProperty(value = "缺陷设备ids")
private String defectEquipmentIds;
@ApiModelProperty(value = "缺陷设备名称")
private String defectEquipmentName;
@ApiModelProperty(value = "缺陷设备类型1-装备2-系统3-水源")
private Integer defectEquipmentType;
@ApiModelProperty(value = "缺陷描述")
private String defectDescribe;
@ApiModelProperty(value = "缺陷来源 1-巡查 2-维保 3-消防检测 4-其他")
private Integer defectResource;
@ApiModelProperty(value = "缺陷类型")
private String defectType;
@ApiModelProperty(value = "缺陷图片")
private String defectImg;
@ApiModelProperty(value = "发现日期")
private Date defectDiscoverDate;
@ApiModelProperty(value = "发现人")
private String defectDiscover;
@ApiModelProperty(value = "计划消缺日期")
private Date planClearDate;
@ApiModelProperty(value = "责任人")
private String defectResponsible;
@ApiModelProperty(value = "处理状态(0:未处理,1:已处理,2:处理中)")
private Integer defectStatus;
@ApiModelProperty(value = "是否需要停电处理(0:不需要,1:需要)")
private Integer isPowerCut;
@ApiModelProperty(value = "换流站名称")
private String bizOrgName;
@ApiModelProperty(value = "机构编码")
private String bizOrgCode;
@ApiModelProperty(value = "公司编码")
private String orgCode;
@ApiModelProperty(value = "添加时间")
private Date addTime;
@ApiModelProperty(value = "处理措施/处理情况")
private String handleSituation;
@ApiModelProperty(value = "处理-图片")
private String handleImg;
@ApiModelProperty(value = "工作票号")
private String handleWorkTicketNum;
@ApiModelProperty(value = "工作负责人")
private String handleWorkLeader;
@ApiModelProperty(value = "工作票是否已消号 1-已消号 0 -未消号")
private Integer handleWorkIdTicket;
@ApiModelProperty(value = "负责人检查日期")
private String handleLeaderDate;
@ApiModelProperty(value = "负责人")
private String handleLeader;
@ApiModelProperty(value = "消缺日期")
private Date handleClearDate;
@ApiModelProperty(value = "消缺人")
private String handleClearPerson;
@ApiModelProperty(value = "缺陷编号")
private String defectNum;
@ApiModelProperty(value = "超期提醒")
private String expiredWarning;
@ApiModelProperty(value = "缺陷状态【装备用】")
private String defectStatusName;
@ApiModelProperty(value = "告警id")
private String specificAlarmLogId;
}
package com.yeejoin.equipmanage.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.equipmanage.common.entity.EquipmentSpecificAlarmLog;
import com.yeejoin.equipmanage.common.entity.MonitorEvent;
import com.yeejoin.equipmanage.common.entity.vo.IdxBizDefectVo;
import com.yeejoin.equipmanage.fegin.IdxFeign;
import com.yeejoin.equipmanage.mapper.EquipmentSpecificAlarmLogMapper;
import com.yeejoin.equipmanage.service.IConfirmAlarmService;
import com.yeejoin.equipmanage.service.impl.MonitorEventService;
......@@ -14,6 +18,7 @@ import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.LinkedHashMap;
import java.util.Map;
......@@ -34,6 +39,8 @@ public class ConfirmAlarmController extends AbstractBaseController {
EquipmentSpecificAlarmLogMapper equipmentSpecificAlarmLogMapper;
@Autowired
private MonitorEventService monitorEventService;
@Autowired
private IdxFeign idxFeign;
@GetMapping(value = "/getDetailsById")
@TycloudOperation(ApiLevel = UserType.AGENCY)
......@@ -98,4 +105,14 @@ public class ConfirmAlarmController extends AbstractBaseController {
public Map<String, Object> getEquipSceneAndRelationVideo(@PathVariable Long equipmentSpecificId) {
return iConfirmAlarmService.getEquipSceneAndRelationVideo(equipmentSpecificId);
}
@GetMapping(value = "/defect/status/{id}")
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "缺陷处理状态")
public IdxBizDefectVo getDefectStatus(@PathVariable String id) {
ResponseModel<JSONObject> responseModel = idxFeign.queryDefectByAlarmLogId(id);
JSONObject result = responseModel.getResult();
IdxBizDefectVo vo = JSON.parseObject(JSON.toJSONString(result), IdxBizDefectVo.class);
return vo;
}
}
package com.yeejoin.equipmanage.fegin;
import com.alibaba.fastjson.JSONObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
/**
* @author DELL
*/
@FeignClient(name = "${idx.feign.name}", path = "idx", configuration = {FeignConfiguration.class})
public interface IdxFeign {
/***
* <pre>
* @Description: 根据告警id查询缺陷治理情况
* </pre>
*
* @MethodName:
* @Param:
* @Return: null
* @Throws
* @Author keyong
* @Date 2022/9/27 17:46
*/
@RequestMapping(value = "/defect/alarm/{alarmLogId}", method = RequestMethod.GET)
ResponseModel<JSONObject> queryDefectByAlarmLogId(@PathVariable String alarmLogId);
}
......@@ -8,7 +8,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yeejoin.amos.boot.module.jcs.api.dto.IotSystemAlarmRo;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.systemctl.model.MessageModel;
import com.yeejoin.equipmanage.common.dto.UserDto;
import com.yeejoin.equipmanage.common.entity.*;
import com.yeejoin.equipmanage.common.entity.vo.AlamVideoVO;
import com.yeejoin.equipmanage.common.enums.*;
......@@ -23,6 +22,7 @@ import com.yeejoin.equipmanage.remote.WebMqttHandler;
import com.yeejoin.equipmanage.service.*;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
......@@ -39,16 +39,24 @@ import java.util.*;
@Service
public class ConfirmAlarmServiceImpl extends ServiceImpl<ConfirmAlarmMapper, EquipmentSpecificAlarm> implements IConfirmAlarmService {
private static final org.slf4j.Logger log = LoggerFactory.getLogger(ConfirmAlarmServiceImpl.class);
private final static String FIELD_NAME = "longitude,latitude";
@Autowired
private RemoteSecurityService remoteSecurityService;
static ConfirmAlarmMapper confirmAlarmMapper;
@Autowired
ConfirmAlarmMapper confirmAlarmMapper;
public void setConfirmAlarmMapper(ConfirmAlarmMapper confirmAlarmMapper){
ConfirmAlarmServiceImpl.confirmAlarmMapper = confirmAlarmMapper;
}
private static JcsFeign jcsFeign;
@Autowired
private JcsFeign jcsFeign;
public void setJcsFeign(JcsFeign jcsFeign){
ConfirmAlarmServiceImpl.jcsFeign = jcsFeign;
}
@Autowired
VideoMapper videoMapper;
......@@ -66,9 +74,12 @@ public class ConfirmAlarmServiceImpl extends ServiceImpl<ConfirmAlarmMapper, Equ
@Autowired
private IEquipmentSpecificAlarmLogService equipmentSpecificAlarmLogService;
private static IEquipmentSpecificSerivce equipmentSpecificSerivce;
@Autowired
@Lazy
private IEquipmentSpecificSerivce equipmentSpecificSerivce;
public void setIEquipmentSpecificIndexSerivce(IEquipmentSpecificSerivce equipmentSpecificSerivce){
ConfirmAlarmServiceImpl.equipmentSpecificSerivce = equipmentSpecificSerivce;
}
@Autowired
private IEquipmentSpecificIndexSerivce iEquipmentSpecificIndexSerivce;
......@@ -88,8 +99,11 @@ public class ConfirmAlarmServiceImpl extends ServiceImpl<ConfirmAlarmMapper, Equ
@Autowired
private SystemctlFeign systemctlFeign;
private static RuleConfirmAlarmService ruleConfirmAlamService;
@Autowired
private RuleConfirmAlarmService ruleConfirmAlamService;
public void setRuleConfirmAlamService(RuleConfirmAlarmService ruleConfirmAlamService){
ConfirmAlarmServiceImpl.ruleConfirmAlamService = ruleConfirmAlamService;
}
@Autowired
private EquipmentSpecificMapper equipmentSpecificMapper;
......@@ -103,8 +117,11 @@ public class ConfirmAlarmServiceImpl extends ServiceImpl<ConfirmAlarmMapper, Equ
@Autowired
private ISignalClassifyService signalClassifyService;
private static IFormInstanceService instanceService;
@Autowired
private IFormInstanceService instanceService;
public void setInstanceService(IFormInstanceService instanceService){
ConfirmAlarmServiceImpl.instanceService = instanceService;
}
@Autowired
private SourceSceneMapper sourceSceneMapper;
......@@ -373,7 +390,7 @@ public class ConfirmAlarmServiceImpl extends ServiceImpl<ConfirmAlarmMapper, Equ
//查询当前建筑是否是 最顶级建筑
public List<FormInstance> selectBuildingById(List<FormInstance> formInstances){
public static List<FormInstance> selectBuildingById(List<FormInstance> formInstances){
if (formInstances.get(0).getGroupType().equals("building")){
return formInstances;
}
......@@ -390,7 +407,7 @@ public class ConfirmAlarmServiceImpl extends ServiceImpl<ConfirmAlarmMapper, Equ
}
public void sendIotSystemAlarm(EquipmentSpecificAlarmLog ent, String userId, String appKey, String product, String token){
public static void sendIotSystemAlarm(EquipmentSpecificAlarmLog ent, String userId, String appKey, String product, String token){
// Token serverToken = remoteSecurityService.getServerToken();
IotSystemAlarmRo confirmAlamVo = new IotSystemAlarmRo();
confirmAlamVo.setId(ent.getId());
......
......@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mchange.v2.beans.swing.TestBean;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.feign.systemctl.model.MessageModel;
import com.yeejoin.equipmanage.common.datasync.entity.FireEquipmentDefectAlarm;
......@@ -86,8 +85,11 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
@Autowired
EquipmentSpecificIndexMapper equipmentSpecificIndexMapper;
static EquipmentSpecificMapper equipmentSpecificMapper;
@Autowired
EquipmentSpecificMapper equipmentSpecificMapper;
public void setEquipmentSpecificMapper(EquipmentSpecificMapper equipmentSpecificMapper){
MqttReceiveServiceImpl.equipmentSpecificMapper = equipmentSpecificMapper;
}
@Autowired
FireFightingSystemMapper FireFightingSystemMapper;
......@@ -129,8 +131,11 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
@Autowired
private SystemctlFeign systemctlFeign;
private static RemoteSecurityService remoteSecurityService;
@Autowired
private RemoteSecurityService remoteSecurityService;
public void setRemoteSecurityService(RemoteSecurityService remoteSecurityService){
MqttReceiveServiceImpl.remoteSecurityService = remoteSecurityService;
}
@Autowired
private TopographyService topographyService;
......@@ -168,6 +173,12 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
@Value("${isSendIot:false}")
private Boolean isSendIot;
private static Boolean jcsSwitch;
@Value("${systemctl.jcs.switch}")
public void setJcsSwitch(Boolean jcsSwitch){
MqttReceiveServiceImpl.jcsSwitch = jcsSwitch;
}
private static Boolean bool = Boolean.FALSE;
@Override
......@@ -407,13 +418,52 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
queryWrapper.ne(EquipmentSpecificAlarmLog::getStatus, AlarmStatusEnum.HF.getCode());
List<EquipmentSpecificAlarmLog> logs = equipmentSpecificAlarmLogService.getBaseMapper()
.selectList(queryWrapper);
EquipmentSpecificAlarmLog log = logs.get(0);
String cleanType = equipmentSpecificMapper.getEquipmentBySpecificId(log.getEquipmentSpecificId());
EquipmentSpecific specific = equipmentSpecificMapper.selectById(log.getEquipmentSpecificId());
Date date = new Date();
logs.forEach(x -> {
x.setCleanTime(new Date());
x.setStatus(AlarmStatusEnum.HF.getCode());
if (!StringUtils.isEmpty(traceId)) {
x.setTraceId(traceId);
}
// 自动确警处理
if (StringUtil.isNotEmpty(cleanType) && AlarmCleanTypeEnum.ZDXC.getCode().equals(cleanType)){
x.setConfirmType(x.getType());
x.setConfirmTypeName(ConfirmAlamEnum.getTypeByCode(x.getType()));
String equipmentName = StringUtil.isNotEmpty(specific.getCode()) ? specific.getName() + "(" + specific.getCode() + ")" : specific.getName();
if (x.getType().equals(AlarmTypeEnum.PB.getCode())) {
x.setAlarmReason(equipmentName + "频繁故障/误报,将设备报警信息屏蔽。");
} else {
x.setAlarmReason(equipmentName + "引起设备报警");
}
x.setResolveResult(date + "系统收到设备复归(已消除)信号,系统自动处理。");
x.setConfirmUser("");
x.setConfirmUserName("系统自动处理");
x.setConfirmDate(date);
}
});
Token token = remoteSecurityService.getServerToken();
String toke = token.getToke();
String appKey = token.getAppKey();
String product = token.getProduct();
String userId = remoteSecurityService.getAgencyUser().getUserId();
if (jcsSwitch && AlarmTypeEnum.HZGJ.getCode().equals(log.getType())) {
// 确警消息发送
if (org.apache.commons.lang3.StringUtils.isNotBlank(userId)) {
new Thread(new Runnable() {
@Override
public void run() {
try {
ConfirmAlarmServiceImpl.sendIotSystemAlarm(log, userId, appKey, product, toke);
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
}
if (!logs.isEmpty()) {
equipmentSpecificAlarmLogService.updateBatchById(logs);
}
......
......@@ -39,6 +39,7 @@ equipManage.name=AMOS-EQUIPMANAGE
iot.vehicle.track=AMOS-API-IOT
jcs.fegin.name=JCS
video.fegin.name=VIDEO
idx.feign.name=AMOS-IDX
#项目初始化画布id
morphic.projectSeq=1390314016458514433
#wl_equipment_category 表id (取火灾报警系统id)
......
......@@ -2998,4 +2998,19 @@
ADD COLUMN `design_org_telephone` varchar(32) NULL COMMENT '设计单位联系方式';
</sql>
</changeSet>
<changeSet author="keyong" id="1664185585-1">
<preConditions onFail="MARK_RAN">
<columnExists tableName="wl_equipment_specific_alarm" columnName="confirm_type"/>
</preConditions>
<comment>删除不需要的属性字段</comment>
<sql>
ALTER TABLE `wl_equipment_specific_alarm` DROP COLUMN `confirm_type`;
ALTER TABLE `wl_equipment_specific_alarm` DROP COLUMN `alam_reason`;
ALTER TABLE `wl_equipment_specific_alarm` DROP COLUMN `resolve_result`;
ALTER TABLE `wl_equipment_specific_alarm` DROP COLUMN `confirm_user`;
ALTER TABLE `wl_equipment_specific_alarm` DROP COLUMN `confirm_user_name`;
ALTER TABLE `wl_equipment_specific_alarm` DROP COLUMN `confirm_date`;
</sql>
</changeSet>
</databaseChangeLog>
\ No newline at end of file
......@@ -30,10 +30,10 @@
f_fire_fighting_system as sys
left join wl_warehouse_structure wws on wws.id = sys.contro_box_build
where 1=1
<if test="equimentName != null and equimentName !='' ">
<if test="equimentName != null and equimentName !='' and equimentCode !='null' ">
AND sys.NAME like CONCAT('%',#{equimentName},'%')
</if>
<if test="equimentCode != null and equimentCode !='' ">
<if test="equimentCode != null and equimentCode !='' and equimentCode !='null' ">
AND sys.CODE like CONCAT('%',#{equimentCode},'%')
</if>
<if test="nameOrCode != null and nameOrCode != ''">
......
......@@ -19,5 +19,9 @@ public class ModelTreeDto {
private String tableName;
private String amosOrgName;
private String modelId;
private List<Map<String, Object>> children;
}
......@@ -46,4 +46,17 @@ public class CheckModel {
@ApiModelProperty(value = "模型图片地址")
private String modelPictureUrl;
@ApiModelProperty(value = "模型规则知识包")
private String modelRule;
@ApiModelProperty(value = "指标模型所属项目id")
private String projectId;
@ApiModelProperty(value = "指标模型表id")
private String tableId;
@ApiModelProperty(value = "模型校验项数量")
private int checkItemAmount;
}
......@@ -34,7 +34,6 @@ public class CheckResult {
@ApiModelProperty(value="检查项值")
private String checkItemValue;
@ApiModelProperty(value="检查项结果")
private String checkItemResult;
......@@ -48,7 +47,7 @@ public class CheckResult {
private String checkExplain;
@ApiModelProperty(value="校验类型")
private String checkType;
private Integer checkType;
@ApiModelProperty(value="模型所属机构")
private String amosOrgCode;
......
......@@ -22,7 +22,7 @@ public interface IdxFeignService {
* @param tableId
* @return
*/
@RequestMapping(value = "/v1/table/{tableId}", method = RequestMethod.GET)
@RequestMapping(value = "/table/{tableId}", method = RequestMethod.GET)
ResponseModel<JSONObject> queryByTableId(@PathVariable String tableId);
/**
......
......@@ -17,9 +17,9 @@ public interface CheckResultMapper extends BaseMapper<CheckResult> {
IPage<CheckResultDto> selectResult(IPage<CheckResultDto> page,String code);
List<CheckResultDto> selectTotal(String modelId, String amosOrgCode);
List<CheckResultDto> selectTotal(String modelId, String batchNo);
Map getTable(String tableName);
Map<String, Object> getTables(String tableName, String amosOrgCode);
List<CheckResultDto> selectStatistion(String batchNo,String amosOrgCode);
......
......@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.yeejoin.amos.boot.module.tdc.api.entity.CheckModel;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author xxz
*/
......@@ -19,9 +21,31 @@ public interface CheckModelService extends IService<CheckModel> {
// List<CheckModel> selectByOrgCode(String amosOrgCode);
IPage<CheckModel> selectByOrgCode(int current, int size, String amosOrgCode);
List<CheckModel> selectByOrgCode(String amosOrgCode);
/**
* 查询最后一次校验模型
* @return 模型obj
*/
CheckModel selectOneByDate(String amosOrgCode);
/**
* 校验机构下全部模型
* @param amosOrgCode 机构code
*/
void checkAllMode(String amosOrgCode);
/**
* 校验单个模型
* @param modelId 模型id
*/
void checkSingleMode(String modelId);
/**
* 根据机构code和模型名称查询模型对象
* @param modelName 模型名称
* @param amosOrgCode 机构code
* @return 模型对象
*/
CheckModel selectCheckModelByNameCode(String modelName, String amosOrgCode);
}
......@@ -16,21 +16,35 @@ public interface CheckResultService extends IService<CheckResult> {
IPage<CheckResultDto> selectResult(int current,int size,String code);
List<CheckResult> selectCheckResult(String modelId,String amosOrgCode);
List<CheckResult> selectCheckResult(String modelId,String batchNo);
List<CheckResultDto> selectTotal(String modelId, String amosOrgCode);
List<ModelTreeDto> test();
ModelTreeDto treeTwo(String tableId);
List<CheckResultDto> selectTotal(String modelId, String batchNo);
List<CheckResultDto> selectStatistion(String batchNo,String amosOrgCode);
List<CheckResultDto> selectDetails(String batchNo,Integer modelId);
String select(String amosOrgCode);
String select(String amosOrgCode,String userName);
/**
* 根据机构code获取模型数据树
* @param amosOrgCode 机构code
* @return 树
*/
List<ModelTreeDto> getAllModelDataTree(String amosOrgCode);
/**
* 根据模型id获取模型数据树
* @param modelId 模型id
* @return 树
*/
List<ModelTreeDto> getModelDataTree(String modelId);
/**
* 根据批次号查询存储属性个数
* @param batchNo 批次号
* @return 属性个数
*/
Integer selectItemCount(String batchNo);
}
......@@ -20,6 +20,6 @@ public class SubjectTreeVo {
private String key;
private List<TableColumnsVo> columns;
private List<TableColumnsVo> tableCols;
}
......@@ -14,12 +14,12 @@
<select id="selectTotal" resultType="com.yeejoin.amos.boot.module.tdc.api.dto.CheckResultDto">
SELECT count(1) as total, COUNT(CASE WHEN (check_item_result=1) THEN check_item_result END) AS aaa
FROM tdc_check_result WHERE model_id = #{modelId} and amos_org_code = #{amosOrgCode}
FROM tdc_check_result WHERE model_id = #{modelId} and batch_no = #{batchNo}
</select>
<select id="getTable" resultType="Map" >
SELECT a.* FROM ${tableName} AS a ORDER BY a.date DESC LIMIT 1
<select id="getTables" resultType="java.util.Map" >
SELECT a.* FROM ${tableName} AS a where a.org_code = #{amosOrgCode} ORDER BY a.date DESC LIMIT 1
</select>
<select id="selectStatistion" resultType="com.yeejoin.amos.boot.module.tdc.api.dto.CheckResultDto">
......@@ -33,7 +33,7 @@
</select>
<select id="getOne" resultType="com.yeejoin.amos.boot.module.tdc.api.dto.CheckResultDto">
select batch_no,model_id from tdc_check_result where amos_org_code = #{amosOrgCode} group by model_name ORDER BY check_date desc limit 0,1;
select amos_org_name,amos_org_code,batch_no,model_id from tdc_check_result where amos_org_code = #{amosOrgCode} group by model_name ORDER BY check_date desc limit 0,1;
</select>
</mapper>
\ No newline at end of file
......@@ -58,24 +58,4 @@ public class AmosTdcApplication {
+ "Application Amos-Biz-Boot is running! Access URLs:\n\t" + "Swagger文档: \thttp://" + ip + ":" + port
+ path + "/doc.html\n" + "----------------------------------------------------------");
}
// /**
// * 初始化MQTT
// *
// * @throws MqttException
// */
// @Bean
// public void initMqtt() throws MqttException {
// emqKeeper.getMqttClient().subscribe("/idx/idx_biz_carcyl_unit_inspect", 1, carcylUnitInspectMqTtlListener);
// emqKeeper.getMqttClient().subscribe("/tm/tz_base_enterprise_info", 1, baseEnterpriseMqTtlListener);
// emqKeeper.getMqttClient().subscribe("/tz/privilege_company_add_update",1, privilegeCompanyUpdateAddListener);
// emqKeeper.getMqttClient().subscribe("/tz/privilege_company_delete",1, privilegeCompanyDeleteListener);
//// emqKeeper.getMqttClient().subscribe("topic_mqtt_exam", 1, examMqTtlListener);
//// emqKeeper.getMqttClient().subscribe("topic_mqtt_exam_record", 1, examMqTtRecordListener);
// }
// @Bean
// public void initToken() {
// startPlatformTokenService.getToken();
// }
}
package com.yeejoin.amos.boot.module.tdc.biz.action;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yeejoin.amos.boot.module.tdc.api.entity.CheckModel;
import com.yeejoin.amos.boot.module.tdc.api.entity.CheckResult;
import com.yeejoin.amos.boot.module.tdc.api.feign.IdxFeignService;
import com.yeejoin.amos.boot.module.tdc.api.service.CheckModelService;
import com.yeejoin.amos.boot.module.tdc.api.service.CheckReportService;
import com.yeejoin.amos.boot.module.tdc.api.service.CheckResultService;
import com.yeejoin.amos.boot.module.tdc.api.vo.SubjectTreeVo;
import com.yeejoin.amos.boot.module.tdc.biz.action.model.IdxProjectModel;
import com.yeejoin.amos.component.rule.MethodParam;
import com.yeejoin.amos.component.rule.RuleActionBean;
import com.yeejoin.amos.component.rule.RuleMethod;
import com.yeejoin.amos.component.rule.config.RuleConfig;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
/**
* @author DELL
*/
@Component
@RuleActionBean(beanLabel = "动态预案")
public class CheckModelAction {
@Autowired
CheckReportService checkReportService;
@Autowired
CheckModelService checkModelService;
@Autowired
CheckResultService checkResultService;
@Autowired
IdxFeignService idxFeignService;
@Autowired
private EmqKeeper emqKeeper;
@Value("${mqtt.topic.check.complete}")
private String checkComplete;
@RuleMethod(methodLabel = "更新检查项结果", project = "保存模型检查项结果")
public void saveCheckItemResult(@MethodParam(paramLabel = "结果") String result,
@MethodParam(paramLabel = "规范标签内容") String checkExplain,
@MethodParam(paramLabel = "校验项") String checkItem,
@MethodParam(paramLabel = "校验项值") String checkItemValue,
@MethodParam(paramLabel = "校验项标准值") String checkItemRealValue,
@MethodParam(paramLabel = "对象") IdxProjectModel idxProjectModel) {
// 1. 检验结果入库
CheckResult checkResult = new CheckResult();
Map propertyValues = idxProjectModel.getPropertyValues();
String batchNo = String.valueOf(propertyValues.get("batch_no"));
Integer checkType = Integer.valueOf(String.valueOf(propertyValues.get("checkType")));
String orgCode = String.valueOf(propertyValues.get("org_code"));
String itemName = idxProjectModel.getItemName();
// 获取模型
CheckModel checkModel = checkModelService.selectCheckModelByNameCode(itemName, orgCode);
if (ObjectUtils.isEmpty(checkModel)) {
return;
}
if (!CollectionUtils.isEmpty(idxProjectModel.getPropertys()) && StringUtils.isNotEmpty(checkItem)) {
Map<String, Object> item = idxProjectModel.getPropertys().stream().filter(map -> checkItem.equals(map.get("name"))).findFirst().orElse(null);
if (ObjectUtils.isNotEmpty(item)) {
checkResult.setCheckItemLabel(String.valueOf(item.get("title")));
}
}
checkResult.setBatchNo(StringUtils.isNotEmpty(batchNo) ? batchNo : String.valueOf(propertyValues.get("id")));
checkResult.setCheckItemResult(result);
checkResult.setCheckExplain(checkExplain);
checkResult.setCheckItem(checkItem);
checkResult.setCheckItemValue(checkItemValue);
checkResult.setModelId(String.valueOf(checkModel.getSequenceNbr()));
checkResult.setAmosOrgCode(checkModel.getAmosOrgCode());
checkResult.setAmosOrgName(checkModel.getAmosOrgName());
checkResult.setCheckDate(new Date());
checkResult.setCheckType(ObjectUtils.isNotEmpty(checkType) ? checkType : 1);
checkResult.setModelName(checkModel.getModelName());
checkResultService.save(checkResult);
// 2. 判断是否检验结束
if (ObjectUtils.isNotEmpty(checkType)) {
if (checkType == 1) {
// 2.2 单独模型校验,根据批次号查询已经入库的属性
sendWebMessage(batchNo, checkModel.getCheckItemAmount());
} else if (checkType == 0) {
// 2.1 全站校验
List<CheckModel> checkModels = checkModelService.selectByOrgCode(orgCode);
int sum = checkModels.stream().mapToInt(CheckModel::getCheckItemAmount).sum();
sendWebMessage(batchNo, sum);
}
}
// else {
// // 指标填报完自动调用,暂时不需要推送前端
// String number = ObjectUtils.isNotEmpty(checkType) ? batchNo : String.valueOf(propertyValues.get("id"));
// Integer itemCount = checkResultService.selectItemCount(number);
// List property = projectModel.getPropertys();
// if (itemCount == property.size()) {
// // 所有属性已全部入库,给前端发送消息
// }
// }
}
private void sendWebMessage(String batchNo, Integer itemSize) {
Integer itemCount = checkResultService.selectItemCount(batchNo);
if (itemCount.equals(itemSize)) {
// 所有属性已全部入库,给前端发送消息
HashMap<String, Object> map = new HashMap<>();
map.put("itemCount", itemCount);
map.put("batchNo", batchNo);
String json=JSONObject.toJSONString(map, SerializerFeature.PrettyFormat,
SerializerFeature.WriteMapNullValue);
try {
emqKeeper.getMqttClient().publish(checkComplete, json.getBytes(), RuleConfig.DEFAULT_QOS, false);
} catch (MqttException e) {
e.printStackTrace();
}
// 全站校验生成报告
}
}
}
package com.yeejoin.amos.boot.module.tdc.biz.action.model;
import com.yeejoin.amos.component.rule.Label;
import com.yeejoin.amos.component.rule.RuleFact;
import liquibase.pro.packaged.L;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* @author DELL
*/
@RuleFact(value = "指标",project = "三维校验")
@RuleFact(value = "指标",project = "三维校验cs")
@Data
public class IdxProjectModel {
/**
* 规则项目id
*/
private String projectSeq;
public class IdxProjectModel implements Serializable {
private static final long serialVersionUID = -8955054152867167436L;
/**
* 规则id
*/
private String ruleSeq;
/**
* 知识包id
* 规则项目id
*/
private String packageId;
// private String projectSeq;
//
// /**
// * 规则id
// */
// private String ruleSeq;
//
// /**
// * 知识包id
// */
// private String packageId;
/**
* 项目名称
*/
private String projectName;
// private String projectName;
/**
* 主题名称
*/
@Label("主题名称")
private String itemName;
/**
* 属性集合
*/
private List propertys;
@Label("属性集合")
private List<Map<String, Object>> propertys;
/**
* 变量属性值
*/
private Map propertyValues;
@Label("变量属性值")
Map<String, Object> propertyValues;
}
......@@ -47,4 +47,23 @@ public class CheckModelController {
return ResponseHelper.buildResponse(checkModelService.selectOneByDate(amosOrgCode));
}
/**
* 点击全站校验
*/
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/CheckAllModel/{amosOrgCode}")
@ApiOperation(httpMethod = "GET",value = "点击全站校验", notes = "根据机构code校验模型")
public void CheckAllModel(@PathVariable(value = "amosOrgCode") String amosOrgCode) {
checkModelService.checkAllMode(amosOrgCode);
}
/**
* 点击单独模型校验
*/
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/checkSingleMode/{modelId}")
@ApiOperation(httpMethod = "GET",value = "点击单独模型校验", notes = "根据modelId校验模型")
public void checkSingleMode(@PathVariable(value = "modelId") String modelId) {
checkModelService.checkSingleMode(modelId);
}
}
......@@ -6,6 +6,7 @@ import com.yeejoin.amos.boot.module.tdc.api.dto.CheckResultDto;
import com.yeejoin.amos.boot.module.tdc.api.dto.ModelTreeDto;
import com.yeejoin.amos.boot.module.tdc.api.entity.CheckResult;
import com.yeejoin.amos.boot.module.tdc.api.service.CheckResultService;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -51,37 +52,30 @@ public class CheckResultController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/selectCheckResult")
@ApiOperation(httpMethod = "GET",value = "查询最后一次校验模型", notes = "查询最后一次校验模型")
public ResponseModel<List<CheckResult>> selectCheckResult( String modelId, String amosOrgCode) {
return ResponseHelper.buildResponse(checkResultService.selectCheckResult(modelId,amosOrgCode));
public ResponseModel<List<CheckResult>> selectCheckResult(String modelId, String batchNo) {
return ResponseHelper.buildResponse(checkResultService.selectCheckResult(modelId,batchNo));
}
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/selectTotal")
@ApiOperation(httpMethod = "GET", value = "result", notes = "result")
public ResponseModel<List<CheckResultDto>> selectTotal(String modelId, String amosOrgCode) {
return ResponseHelper.buildResponse(checkResultService.selectTotal(modelId, amosOrgCode));
public ResponseModel<List<CheckResultDto>> selectTotal(String modelId, String batchNo) {
return ResponseHelper.buildResponse(checkResultService.selectTotal(modelId, batchNo));
}
/**
* 根据amosOrgCode、modelId查询不合格项
* return
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/selectCheckResult/test")
@ApiOperation(httpMethod = "GET",value = "查询最后一次校验模型", notes = "查询最后一次校验模型")
public ResponseModel<List<ModelTreeDto>> test() {
return ResponseHelper.buildResponse(checkResultService.test());
@GetMapping(value = "/getAllModelDataTree/{amosOrgCode}")
@ApiOperation(httpMethod = "GET",value = "获取机构下模型树", notes = "根据机构code获取模型树")
public ResponseModel<List<ModelTreeDto>> getAllModelDataTree(@PathVariable(value = "amosOrgCode") String amosOrgCode) {
return ResponseHelper.buildResponse(checkResultService.getAllModelDataTree(amosOrgCode));
}
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/selectCheckResult/TreeTwo")
@ApiOperation(httpMethod = "GET",value = "查询最后一次校验模型", notes = "查询最后一次校验模型")
public ResponseModel<ModelTreeDto> treeTwo(String tableId) {
return ResponseHelper.buildResponse(checkResultService.treeTwo(tableId));
@GetMapping(value = "/getModelDataTree/{modelId}")
@ApiOperation(httpMethod = "GET",value = "获取单独模型树", notes = "根据模型id获取模型树")
public ResponseModel<List<ModelTreeDto>> getModelDataTree(@PathVariable(value = "modelId") String modelId) {
return ResponseHelper.buildResponse(checkResultService.getModelDataTree(modelId));
}
......@@ -102,7 +96,8 @@ public class CheckResultController extends BaseController {
@GetMapping(value = "/select")
@ApiOperation(httpMethod = "GET", value = "result", notes = "result")
public ResponseModel<String> select(String amosOrgCode) {
return ResponseHelper.buildResponse(checkResultService.select(amosOrgCode));
AgencyUserModel user = getUserInfo();
return ResponseHelper.buildResponse(checkResultService.select(amosOrgCode,user.getUserName()));
}
......
package com.yeejoin.amos.boot.module.tdc.biz.service.impl;
import com.alibaba.excel.util.CollectionUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yeejoin.amos.boot.module.tdc.api.entity.CheckModel;
import com.yeejoin.amos.boot.module.tdc.api.entity.CheckReport;
import com.yeejoin.amos.boot.module.tdc.api.entity.CheckResult;
import com.yeejoin.amos.boot.module.tdc.api.feign.IdxFeignService;
import com.yeejoin.amos.boot.module.tdc.api.mapper.CheckModelMapper;
import com.yeejoin.amos.boot.module.tdc.api.mapper.CheckResultMapper;
import com.yeejoin.amos.boot.module.tdc.api.service.CheckModelService;
import com.yeejoin.amos.boot.module.tdc.api.vo.SubjectTreeVo;
import com.yeejoin.amos.boot.module.tdc.api.vo.TableColumnsVo;
import com.yeejoin.amos.boot.module.tdc.biz.action.model.IdxProjectModel;
import com.yeejoin.amos.component.rule.RuleTrigger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.*;
/**
* @author xxz
*/
@Service
public class CheckModelImpl extends ServiceImpl<CheckModelMapper, CheckModel> implements CheckModelService {
@Autowired
CheckResultMapper checkResultMapper;
@Autowired
IdxFeignService idxFeignService;
@Autowired
RuleTrigger ruleTrigger;
@Override
public IPage<CheckModel> selectByOrgCode(int current, int size, String amosOrgCode) {
Page page = new Page(current,size);
......@@ -35,6 +61,13 @@ public class CheckModelImpl extends ServiceImpl<CheckModelMapper, CheckModel> im
}
@Override
public List<CheckModel> selectByOrgCode(String amosOrgCode) {
LambdaQueryWrapper<CheckModel> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CheckModel::getAmosOrgCode, amosOrgCode);
return baseMapper.selectList(wrapper);
}
@Override
public CheckModel selectOneByDate(String amosOrgCode) {
LambdaQueryWrapper<CheckModel> wrapper = new LambdaQueryWrapper<>();
wrapper
......@@ -44,5 +77,78 @@ public class CheckModelImpl extends ServiceImpl<CheckModelMapper, CheckModel> im
.last("limit 1");
return baseMapper.selectOne(wrapper);
}
@Override
public void checkAllMode(String amosOrgCode) {
LambdaQueryWrapper<CheckModel> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CheckModel::getAmosOrgCode, amosOrgCode);
List<CheckModel> checkModels = this.baseMapper.selectList(wrapper);
String batchNo = UUID.randomUUID().toString();
if (!CollectionUtils.isEmpty(checkModels)) {
checkModels.forEach(checkModel -> {
checkModelRule(checkModel, 0, batchNo, amosOrgCode);
});
}
}
@Override
public void checkSingleMode(String modelId) {
LambdaQueryWrapper<CheckModel> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CheckModel::getSequenceNbr, modelId);
CheckModel checkModel = this.baseMapper.selectOne(wrapper);
if (!ObjectUtils.isEmpty(checkModel)) {
// 调用规则校验模型
String batchNo = UUID.randomUUID().toString();
checkModelRule(checkModel, 1, batchNo, checkModel.getAmosOrgCode());
}
}
@Override
public CheckModel selectCheckModelByNameCode(String modelName, String amosOrgCode) {
LambdaQueryWrapper<CheckModel> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CheckModel::getAmosOrgCode, amosOrgCode);
wrapper.eq(CheckModel::getModelName, modelName);
return this.baseMapper.selectOne(wrapper);
}
private void checkModelRule(CheckModel checkModel, int checkType, String batchNo, String amosOrgCode) {
IdxProjectModel idxProjectModel = new IdxProjectModel();
// 查询表最新一条数据
String idxTableName = checkModel.getIdxTableName();
Map<String, Object> map = checkResultMapper.getTables(idxTableName, amosOrgCode);
// Map<String, Object> map = new HashMap<>();
if (ObjectUtils.isEmpty(map)) {
new RuntimeException("暂无填报数据");
}
map.put("batch_no", batchNo);
map.put("checkType", checkType);
// 查询表所有字段
ResponseModel<JSONObject> model = idxFeignService.queryByTableId(checkModel.getTableId());
JSONObject result = model.getResult();
SubjectTreeVo subjectTreeVo = JSON.parseObject(JSON.toJSONString(result), SubjectTreeVo.class);
List<TableColumnsVo> columns = subjectTreeVo.getTableCols();
List<Map<String, Object>> list = new ArrayList<>();
columns.forEach(tableColumnsVo -> {
Map<String, Object> itemMap = new HashMap<>(3);
itemMap.put("name", tableColumnsVo.getColumnName());
itemMap.put("title", tableColumnsVo.getName());
itemMap.put("type", tableColumnsVo.getColumnType());
list.add(itemMap);
});
idxProjectModel.setPropertys(list);
idxProjectModel.setItemName(checkModel.getModelName());
idxProjectModel.setPropertyValues(map);
// 调用规则校验模型
try {
// 没有配决策流,processIds传null即可
ruleTrigger.publish(idxProjectModel, checkModel.getModelRule(), null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
......@@ -22,7 +22,7 @@ public class CheckReportImpl extends ServiceImpl<CheckReportMapper, CheckReport>
@Override
public IPage<CheckReport> selectAll(int current,int size,String amosOrgCode) {
Page page = new Page(current,size);
Page<CheckReport> page = new Page<>(current,size);
if(ValidationUtil.isEmpty(amosOrgCode)){
return this.page(page);
......@@ -33,6 +33,4 @@ public class CheckReportImpl extends ServiceImpl<CheckReportMapper, CheckReport>
}
}
}
spring.application.name=TDC-LM
spring.application.name=AMOS-TDC
server.servlet.context-path=/tdc
server.port=13000
......@@ -40,3 +40,6 @@ spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
## redis失效时间
redis.cache.failure.time=10800
#校验完成发送消息
mqtt.topic.check.complete=/tdc/check/complete
......@@ -25,4 +25,5 @@ public interface IdxFeignService {
*/
@RequestMapping(value = "/table/{tableId}", method = RequestMethod.GET)
ResponseModel<JSONObject> queryByTableId(@PathVariable String tableId);
}
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