Commit 07a55474 authored by litengwei's avatar litengwei

每日至少一次进行防火巡查

parent 75d8a9a9
......@@ -15,7 +15,7 @@ import lombok.Getter;
@AllArgsConstructor
public enum RiskSourceTypeEnum {
EQUIP("equip", "装备告警"), PATROL("patrol", "巡检异常"),
HIDDENDANGER("danger", "隐患"), DEFECT("defect", "缺陷");
HIDDENDANGER("danger", "隐患"), DEFECT("defect", "缺陷"), SCRAP("scrap", "报废");
private String name;
......
......@@ -24,7 +24,7 @@ public class DateUtils {
private static final Logger logs = LoggerFactory.getLogger(DateUtils.class);
public static final String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
public static final String DATE_TIME_TT_PATTERN = "yyyy-MM-dd'T'HH:mm:ss";
public static final String DATE_TIME_TT_PATTERN = "yyyy-MM-dd'T'HH:mm";
public static final String MINUTE_PATTERN = "yyyy-MM-dd HH:mm";
public static final String HOUR_PATTERN = "yyyy-MM-dd HH";
public static final String DATE_PATTERN = "yyyy-MM-dd";
......
......@@ -112,6 +112,8 @@ public interface EquipmentSpecificIndexMapper extends BaseMapper<EquipmentSpecif
List<Map<String, Object>> getEquipSpecificScrap();
Map<String, Object> patrolTaskStatic();
List<EquipmentSpecificIndex> getEquipIndexInIndex(@Param("list") List<String> listIndex);
EquipmentSpecificIndex getEquipmentSpeIndexByAddress(String indexAddress, String eventAddress, String gatewayId);
......
......@@ -37,6 +37,7 @@ import com.yeejoin.equipmanage.mapper.*;
import com.yeejoin.equipmanage.remote.RemoteSecurityService;
import com.yeejoin.equipmanage.service.*;
import com.yeejoin.equipmanage.utils.RelationRedisUtil;
import liquibase.pro.packaged.J;
import liquibase.pro.packaged.S;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
......@@ -1949,7 +1950,7 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
try {
if (e.get("weExpiry") != null) {
int year = Integer.parseInt(e.get("weExpiry").toString());
Date productDate = DateUtils.dateParse(e.get("product").toString(), DateUtils.DATE_TIME_TT_PATTERN);
Date productDate = DateUtils.dateParse(e.get("product").toString().substring(0,9), DateUtils.DATE_PATTERN);
Calendar calendar = Calendar.getInstance();
calendar.setTime(productDate);
calendar.add(Calendar.YEAR, year);
......@@ -1961,23 +1962,19 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
if (day < Integer.parseInt(equipmentScrapDay) && day > -1) {
syncSystemctlMsg(e, scrapTime, day);
} else if (day == -1) {
// 发送emq消息转kafka
JSONObject jsonObject = new JSONObject();
// 发送emq消息 给idx
Map<String, String> map = new HashMap<>();
map.put("id", e.get("id").toString());
map.put("code", e.get("code").toString());
map.put("bizOrgCode", e.get("bizOrgCode").toString());
map.put("bizOrgName", e.get("bizOrgName").toString());
jsonObject.put("topic", "equip/scrap/put");
jsonObject.put("data", JSONObject.toJSON(map));
//
try {
emqKeeper.getMqttClient().publish("emq.scrap.qrcode.put", jsonObject.toString().getBytes(), 1, false);
emqKeeper.getMqttClient().publish("equip/scrap/put", JSONObject.toJSONString(map).getBytes(), 1, false);
} catch (MqttException exp) {
log.info(String.format("发送eqm转kafka消息失败:%s", exp.getMessage()));
}
idxFeign.handleEquipNotScrapWhenExpired(String.valueOf(e.get("id")), String.valueOf(e.get("bizOrgCode")), String.valueOf(e.get("bizOrgName")));
// idxFeign.handleEquipNotScrapWhenExpired(String.valueOf(e.get("id")), String.valueOf(e.get("bizOrgCode")), String.valueOf(e.get("bizOrgName")));
}
}
......@@ -1988,6 +1985,30 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
}
/**
* 每日计算当天巡检任务数量,任务是否至少有一次执行。。
*
* @throws Exception
*/
@Scheduled(cron = "${equip.patrol.cron:0 0 9 * * ?}")
@Transactional(rollbackFor = Exception.class)
public void patrolTaskStatic() throws Exception {
Map<String, Object> mapPatrol = equipmentSpecificIndexMapper.patrolTaskStatic();
Map<String, String> map = new HashMap<>();
map.put("isFinishOnce", mapPatrol.get("isFinishOnce").toString());
map.put("taskNum", mapPatrol.get("taskNum").toString());
map.put("planNum", mapPatrol.get("planNum").toString());
map.put("bizOrgCode", mapPatrol.get("bizOrgCode").toString());
map.put("bizOrgName", mapPatrol.get("bizOrgName").toString());
try {
log.info("每日统计当天巡检任务情况:{}===========", map);
emqKeeper.getMqttClient().publish("equip/patrol/put", JSONObject.toJSONString(map).getBytes(), 1, false);
} catch (MqttException exp) {
log.info(String.format("发送eqm转kafka消息失败:%s", exp.getMessage()));
}
}
void syncSystemctlMsg(Map<String, Object> map, String scrapTime, int i) {
try {
MessageModel model = new MessageModel();
......
......@@ -137,7 +137,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
equipInfoVo.setBatchNo(getEquipmentDetailInfo(specific.getEquipmentDetailId()).getStandard());
equipInfoVo.setBizOrgCode(specific.getBizOrgCode());
equipInfoVo.setBizOrgName(specific.getBizOrgName());
if (source.equalsIgnoreCase(RiskSourceTypeEnum.HIDDENDANGER.getName()) || source.equalsIgnoreCase(RiskSourceTypeEnum.DEFECT.getName())) {
equipInfoVo.setName(specific.getName());
equipInfoVo.setCode(specific.getCode());
if (source.equalsIgnoreCase(RiskSourceTypeEnum.HIDDENDANGER.getName()) || source.equalsIgnoreCase(RiskSourceTypeEnum.DEFECT.getName()) || source.equalsIgnoreCase(RiskSourceTypeEnum.SCRAP.getName())) {
equipInfoVo.setName(specific.getName());
equipInfoVo.setCode(specific.getCode());
equipInfoVo.setReportIsAlarm(Boolean.TRUE);
......@@ -190,16 +192,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
contentVo.setValue(equipInfoVo.getSystemName());
contentVo.setType("text");
break;
case "qrCode":
contentVo.setLabel(u.getDescribe());
Map<String, Object> map = new HashMap<>();
map.put("qrCode", equipInfoVo.getQrCode());
map.put("color", equipInfoVo.getCodeColor());
contentVo.setValue(map);
contentVo.setType("qrcode");
break;
case "alarmContent":
if(!source.equalsIgnoreCase(RiskSourceTypeEnum.PATROL.getName())) {
if(!source.equalsIgnoreCase(RiskSourceTypeEnum.PATROL.getName()) && !source.equalsIgnoreCase(RiskSourceTypeEnum.SCRAP.getName())) {
contentVo.setLabel(u.getDescribe());
contentVo.setValue(equipAlarm.getAlarmContent());
contentVo.setType("text");
......@@ -208,7 +202,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
break;
}
case "alarmDate":
if(!source.equalsIgnoreCase(RiskSourceTypeEnum.PATROL.getName())) {
if(!source.equalsIgnoreCase(RiskSourceTypeEnum.PATROL.getName()) && !source.equalsIgnoreCase(RiskSourceTypeEnum.SCRAP.getName())) {
contentVo.setLabel(u.getDescribe());
contentVo.setValue(equipAlarm.getAlarmDate());
contentVo.setType("text");
......@@ -263,5 +257,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
});
return sb.toString();
}
}
......@@ -495,6 +495,24 @@
where wed.production_date is not null
</select>
<select id="patrolTaskStatic" resultType="java.util.Map">
SELECT
IFNULL( IF ( sum( IF ( ppt.finish_status = '2', 1, 0 ) ) > 0, 1, 0 ), 0 ) AS isFinishOnce,
IFNULL( sum( 1 ), 0 ) AS taskNum,
pp.biz_org_code bizOrgCode,
pp.biz_org_name bizOrgName,
(
SELECT
count( 1 )
FROM
( SELECT ppt.id FROM `p_plan_task` ppt LEFT JOIN `p_plan` pp ON pp.id = ppt.plan_id where ppt.check_date = DATE_FORMAT( now(), '%Y-%m-%d' ) GROUP BY ppt.plan_id ) temp
) AS planNum
FROM
`p_plan_task` ppt
LEFT JOIN `p_plan` pp ON pp.id = ppt.plan_id
where ppt.check_date = DATE_FORMAT( now(), '%Y-%m-%d' )
</select>
<select id="getEquipIndexInIndex" resultType="com.yeejoin.equipmanage.common.entity.EquipmentSpecificIndex">
SELECT
si.equipment_specific_id AS equipmentId,
......
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