Commit 1a17a5b1 by TEEMO\xzh64

修改设备日志记录

parent 9ee9530d
......@@ -75,5 +75,9 @@ public class HPConstants {
/** 设备状态 */
public static final String STARUS_TYPE = "STARUS_TYPE";
public static final String TIME_TYPE = "TIME_TYPE";
public static final String WARNING_TYPE = "WARNING_TYPE";
}
......@@ -3,6 +3,7 @@ package com.baosight.hpjx.controller;
import com.baosight.hpjx.common.HPConstants;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.equipment.hp.domain.CutterbarStatus;
import com.baosight.hpjx.equipment.hp.domain.CutterbarTime;
import com.baosight.hpjx.equipment.hp.domain.CutterbarWarning;
import com.baosight.hpjx.equipment.hp.domain.CutterbarWarningBase;
import com.baosight.hpjx.hp.sb.domain.HPSB001;
......@@ -28,71 +29,55 @@ public class LogInformationController extends ServiceBase {
@RequestMapping({"/analysis"})
public String logAnalysis(@PathVariable HPSB00A hpsb00A) {
HPSB002 hpsb002 = new HPSB002();
HPSB001 hpsb001 = new HPSB001();
//TODO 根据TYPE来判断内容属于哪一种,然后再进行解析
//TODO TYPE = STARUS_TYPE --- 设备状态
//TODO TYPE = TIME_TYPE --- 开机时间
//TODO TYPE = WARNING_TYPE --- 报警内容
String equipmentType = hpsb00A.getEquipmentType();
if (StringUtils.isEmpty(equipmentType)) {
if (equipmentType.equals(HPConstants.STARUS_TYPE)){
if (equipmentType.equals(HPConstants.STARUS_TYPE)) {
//解析设备状态
List<CutterbarStatus> cutterbarStatusList = XmlUtils.readXml(hpsb00A.getDataContent(), CutterbarStatus.class);
hpsb002.setId(StringUtils.uuid());
hpsb002.setEquipmentCode(hpsb00A.getEquipmentCode());
hpsb002.setEquipmentType(hpsb00A.getEquipmentType());
hpsb002.setLogValue(cutterbarStatusList.get(0).getStatus().toString());
DaoUtils.insert("HPSB002.insert", hpsb002);
return "设备日志记录成功";
}
if (equipmentType.equals(HPConstants.TIME_TYPE)) {
//解析开机时间
List<CutterbarTime> cutterbarTimeList = XmlUtils.readXml(hpsb00A.getDataContent(), CutterbarTime.class);
hpsb002.setId(StringUtils.uuid());
hpsb002.setEquipmentCode(hpsb00A.getEquipmentCode());
hpsb002.setEquipmentType(hpsb00A.getEquipmentType());
hpsb002.setLogValue(cutterbarTimeList.get(0).getTime());
DaoUtils.insert("HPSB002.insert", hpsb002);
return "设备日志记录成功";
}
if (equipmentType.equals(HPConstants.WARNING_TYPE)) {
//解析报警内容
List<CutterbarWarningBase> cutterbarWarningBaseList = XmlUtils.readXml(hpsb00A.getDataContent(), CutterbarWarningBase.class);
CutterbarWarning cutterbarWarning = new CutterbarWarning();
if (CollectionUtils.isNotEmpty(cutterbarWarningBaseList)) {
cutterbarWarning = CutterbarWarning.convertBase(cutterbarWarningBaseList.get(0));
}
hpsb001.setId(StringUtils.uuid());
hpsb001.setErrorCode(cutterbarWarning.getErrorCode());
hpsb001.setPrio(cutterbarWarning.getPrio());
hpsb001.setProgramNo(cutterbarWarning.getProgramNo());
hpsb001.setRowno(cutterbarWarning.getRowNo());
hpsb001.setGotoRowNone(cutterbarWarning.getGotoRowNone());
hpsb001.setFileName(cutterbarWarning.getFileName());
hpsb001.setEquipmentCode(hpsb00A.getEquipmentCode());
hpsb001.setEquipmentType(hpsb00A.getEquipmentType());
DaoUtils.insert("HPSB001.insert", hpsb001);
return "设备异常日志记录成功";
}
} else {
}
HPSB002 hpsb002 = new HPSB002();
HPSB001 hpsb001 = new HPSB001();
//解析设备状态
List<CutterbarStatus> cutterbarStatusList = XmlUtils.readXml(hpsb00A.getEquipmentType(), CutterbarStatus.class);
String value = "";
if (cutterbarStatusList.get(0).getStatus() == 1){
value = "默认状态";
} else if (cutterbarStatusList.get(0).getStatus() == 2){
value = "运行状态";
} else if (cutterbarStatusList.get(0).getStatus() == 3){
value = "暂停状态";
} else if (cutterbarStatusList.get(0).getStatus() == 4){
value = "复位状态";
} else if (cutterbarStatusList.get(0).getStatus() == 5){
value = "一级报警状态";
} else if (cutterbarStatusList.get(0).getStatus() == 6){
value = "二级报警状态";
}
//解析数据内容
List<CutterbarWarningBase> cutterbarWarningBaseList = XmlUtils.readXml(hpsb00A.getDataContent(), CutterbarWarningBase.class);
CutterbarWarning cutterbarWarning = new CutterbarWarning();
if (CollectionUtils.isNotEmpty(cutterbarWarningBaseList)) {
cutterbarWarning = CutterbarWarning.convertBase(cutterbarWarningBaseList.get(0));
}
if (cutterbarStatusList.get(0).getStatus() > 2) {
hpsb001.setId(StringUtils.uuid());
hpsb001.setErrorCode(cutterbarWarning.getErrorCode());
hpsb001.setPrio(cutterbarWarning.getPrio());
hpsb001.setProgramNo(cutterbarWarning.getProgramNo());
hpsb001.setRowno(cutterbarWarning.getRowNo());
hpsb001.setGotoRowNone(cutterbarWarning.getGotoRowNone());
hpsb001.setFileName(cutterbarWarning.getFileName());
hpsb001.setEquipmentCode(hpsb00A.getEquipmentCode());
hpsb001.setEquipmentType(value);
DaoUtils.insert("HPSB001.insert", hpsb001);
return "设备异常日志记录成功";
}
hpsb002.setId(StringUtils.uuid());
hpsb002.setProgramNo(cutterbarWarning.getProgramNo());
hpsb002.setErrorCode(cutterbarWarning.getErrorCode());
hpsb002.setPrio(cutterbarWarning.getPrio());
hpsb002.setRowno(cutterbarWarning.getRowNo());
hpsb002.setGotoRowNone(cutterbarWarning.getGotoRowNone());
hpsb002.setFileName(cutterbarWarning.getFileName());
hpsb002.setEquipmentCode(hpsb00A.getEquipmentCode());
hpsb002.setEquipmentType(value);
DaoUtils.insert("HPSB002.insert", hpsb002);
return "设备日志记录成功";
return "未解析到日志类型";
}
}
package com.baosight.hpjx.equipment.hp.domain;
import com.baosight.hpjx.xml.IXml;
import com.baosight.hpjx.xml.XmlUtils;
import lombok.Data;
import java.util.List;
/**
* @Author xzh
* @Date 2024/4/17 9:22
*/
@Data
public class CutterbarTime {
@IXml(nodeName = "tm")
private String time;
public static void main(String[] args) {
List<CutterbarTime> list = XmlUtils.readXml("<startTime><tm>2020-7-29 14:30:25</tm></startTime>", CutterbarTime.class);
System.out.println(list.get(0).getTime());
}
}
package com.baosight.hpjx.hp.sb.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.core.security.UserSessionUtils;
import com.baosight.hpjx.hp.sb.domain.HPSB001;
import com.baosight.hpjx.hp.sc.domain.HPSC001;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
......@@ -10,7 +16,9 @@ import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
......@@ -61,7 +69,7 @@ public class ServiceHPSB001 extends ServiceBase {
hpsb001.setCreatedTime(sdf.format(new Date()));
hpsb001.setUpdatedBy(null);
hpsb001.setUpdatedTime(null);
this.dao.insert("HPSB001.insert", hpsb001.toMap());
DaoUtils.insert("HPSB001.insert", hpsb001.toMap());
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg("新增成功!");
......@@ -91,7 +99,7 @@ public class ServiceHPSB001 extends ServiceBase {
hpsb001.fromMap(map);
hpsb001.setUpdatedBy(UserSession.getUserId());
hpsb001.setUpdatedTime(sdf.format(new Date()));
this.dao.update("HPSB001.update", hpsb001.toMap());
DaoUtils.update("HPSB001.update", hpsb001.toMap());
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg("修改成功!");
......@@ -107,7 +115,7 @@ public class ServiceHPSB001 extends ServiceBase {
/**
* 删除操作.
*/
*
@OperationLogAnnotation(operModul = "设备异常日志",operType = "删除",operDesc = "删除")
public EiInfo delete(EiInfo eiInfo) {
HPSB001 hpsb001 = new HPSB001();
......@@ -130,7 +138,7 @@ public class ServiceHPSB001 extends ServiceBase {
eiInfo.setStatus(EiConstant.STATUS_SUCCESS);
eiInfo.setMsg("删除成功!");
return eiInfo;
}
}*/
/**
* 定时删除操作.
......
package com.baosight.hpjx.hp.sb.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.sb.domain.HPSB002;
import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiConstant;
......@@ -61,7 +62,7 @@ public class ServiceHPSB002 extends ServiceBase {
hpsb002.setCreatedTime(sdf.format(new Date()));
hpsb002.setUpdatedBy(null);
hpsb002.setUpdatedTime(null);
this.dao.insert("HPSB002.insert", hpsb002.toMap());
DaoUtils.insert("HPSB002.insert", hpsb002.toMap());
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg("新增成功!");
......@@ -91,7 +92,7 @@ public class ServiceHPSB002 extends ServiceBase {
hpsb002.fromMap(map);
hpsb002.setUpdatedBy(UserSession.getUserId());
hpsb002.setUpdatedTime(sdf.format(new Date()));
this.dao.update("HPSB002.update", hpsb002.toMap());
DaoUtils.update("HPSB002.update", hpsb002.toMap());
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg("修改成功!");
......@@ -107,7 +108,7 @@ public class ServiceHPSB002 extends ServiceBase {
/**
* 删除操作.
*/
*
@OperationLogAnnotation(operModul = "设备日志",operType = "删除",operDesc = "删除")
public EiInfo delete(EiInfo eiInfo) {
HPSB002 hpsb002 = new HPSB002();
......@@ -131,6 +132,7 @@ public class ServiceHPSB002 extends ServiceBase {
eiInfo.setMsg("删除成功!");
return eiInfo;
}
*/
/**
* 定时删除操作.
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<!-- table information
Generate time : 2024-04-12 16:36:57
Version : 1.0
tableName :hpjx.t_hpsb002
ID VARCHAR NOT NULL primarykey,
PROGRAM_NO VARCHAR,
ROWNO VARCHAR,
GOTO_ROW_NONE VARCHAR,
FILE_NAME VARCHAR,
EQUIPMENT_TYPE VARCHAR,
EQUIPMENT_CODE VARCHAR,
CREATED_BY VARCHAR,
CREATED_NAME VARCHAR,
CREATED_TIME VARCHAR,
UPDATED_BY VARCHAR,
UPDATED_NAME VARCHAR,
UPDATED_TIME VARCHAR,
DELETE_FLAG TINYINT,
ERROR_CODE VARCHAR,
PRIO VARCHAR
-->
<sqlMap namespace="HPSB002">
<select id="query" parameterClass="java.util.HashMap"
resultClass="com.baosight.hpjx.hp.sb.domain.HPSB002">
SELECT
ID as "id", <!-- ID -->
PROGRAM_NO as "programNo", <!-- 程序号 -->
ROWNO as "rowno", <!-- 行号 -->
GOTO_ROW_NONE as "gotoRowNone", <!-- 不存在跳转行 -->
FILE_NAME as "fileName", <!-- 文件名 -->
EQUIPMENT_TYPE as "equipmentType", <!-- 设备状态 -->
EQUIPMENT_CODE as "equipmentCode", <!-- 设备编码 -->
CREATED_BY as "createdBy", <!-- 创建人 -->
CREATED_NAME as "createdName", <!-- 创建人名称 -->
CREATED_TIME as "createdTime", <!-- 创建时间 -->
UPDATED_BY as "updatedBy", <!-- 更新人 -->
UPDATED_NAME as "updatedName", <!-- 更新人名称 -->
UPDATED_TIME as "updatedTime", <!-- 更新时间 -->
DELETE_FLAG as "deleteFlag", <!-- 是否删除0.否1.是 -->
ERROR_CODE as "errorCode", <!-- 异常编码 -->
PRIO as "prio" <!-- 异常登记 -->
FROM hpjx.t_hpsb002 WHERE 1=1
<isNotEmpty prepend=" AND " property="id">
ID = #id#
</isNotEmpty>
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
ID asc
</isEmpty>
</dynamic>
</select>
<select id="count" resultClass="int">
SELECT COUNT(*) FROM hpjx.t_hpsb002 WHERE 1=1
<isNotEmpty prepend=" AND " property="id">
ID = #id#
</isNotEmpty>
</select>
<!--
<isNotEmpty prepend=" AND " property="id">
ID = #id#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="programNo">
PROGRAM_NO = #programNo#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="rowno">
ROWNO = #rowno#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="gotoRowNone">
GOTO_ROW_NONE = #gotoRowNone#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="fileName">
FILE_NAME = #fileName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="equipmentType">
EQUIPMENT_TYPE = #equipmentType#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="equipmentCode">
EQUIPMENT_CODE = #equipmentCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdBy">
CREATED_BY = #createdBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdName">
CREATED_NAME = #createdName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="createdTime">
CREATED_TIME = #createdTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedBy">
UPDATED_BY = #updatedBy#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedName">
UPDATED_NAME = #updatedName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="updatedTime">
UPDATED_TIME = #updatedTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="deleteFlag">
DELETE_FLAG = #deleteFlag#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="errorCode">
ERROR_CODE = #errorCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="prio">
PRIO = #prio#
</isNotEmpty>
-->
<insert id="insert">
INSERT INTO hpjx.t_hpsb002 (ID, <!-- ID -->
PROGRAM_NO, <!-- 程序号 -->
ROWNO, <!-- 行号 -->
GOTO_ROW_NONE, <!-- 不存在跳转行 -->
FILE_NAME, <!-- 文件名 -->
EQUIPMENT_TYPE, <!-- 设备状态 -->
EQUIPMENT_CODE, <!-- 设备编码 -->
CREATED_BY, <!-- 创建人 -->
CREATED_NAME, <!-- 创建人名称 -->
CREATED_TIME, <!-- 创建时间 -->
UPDATED_BY, <!-- 更新人 -->
UPDATED_NAME, <!-- 更新人名称 -->
UPDATED_TIME, <!-- 更新时间 -->
DELETE_FLAG, <!-- 是否删除0.否1.是 -->
ERROR_CODE, <!-- 异常编码 -->
PRIO <!-- 异常登记 -->
)
VALUES (#id#, #programNo#, #rowno#, #gotoRowNone#, #fileName#, #equipmentType#, #equipmentCode#, #createdBy#, #createdName#, #createdTime#, #updatedBy#, #updatedName#, #updatedTime#, #deleteFlag#, #errorCode#, #prio#)
</insert>
<delete id="delete">
DELETE FROM hpjx.t_hpsb002 WHERE
ID = #id#
</delete>
<delete id="deleteByCreatedTime">
DELETE FROM hpjx.t_hpsb002 WHERE
SUBSTR(CREATED_TIME,1,8) &lt; DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 30 day),'%Y%m%d')
</delete>
<update id="update">
UPDATE hpjx.t_hpsb002
SET
PROGRAM_NO = #programNo#, <!-- 程序号 -->
ROWNO = #rowno#, <!-- 行号 -->
GOTO_ROW_NONE = #gotoRowNone#, <!-- 不存在跳转行 -->
FILE_NAME = #fileName#, <!-- 文件名 -->
EQUIPMENT_TYPE = #equipmentType#, <!-- 设备状态 -->
EQUIPMENT_CODE = #equipmentCode#, <!-- 设备编码 -->
CREATED_BY = #createdBy#, <!-- 创建人 -->
CREATED_NAME = #createdName#, <!-- 创建人名称 -->
CREATED_TIME = #createdTime#, <!-- 创建时间 -->
UPDATED_BY = #updatedBy#, <!-- 更新人 -->
UPDATED_NAME = #updatedName#, <!-- 更新人名称 -->
UPDATED_TIME = #updatedTime#, <!-- 更新时间 -->
DELETE_FLAG = #deleteFlag#, <!-- 是否删除0.否1.是 -->
ERROR_CODE = #errorCode#, <!-- 异常编码 -->
PRIO = #prio# <!-- 异常登记 -->
WHERE
ID = #id#
</update>
</sqlMap>
\ No newline at end of file
......@@ -10,7 +10,7 @@
<EF:EFRegion id="inqu" title="查询条件">
<div class="row">
<EF:EFInput cname="操作人" ename="inqu_status-0-createdName" colWidth="3"/>
<EF:EFInput cname="程序号" ename="inqu_status-0-programNo" colWidth="3"/>
<EF:EFInput cname="异常编码" ename="inqu_status-0-errorCode" colWidth="3"/>
</div>
</EF:EFRegion>
......@@ -22,7 +22,10 @@
<EF:EFColumn ename="programNo" cname="程序号" enable="false" readonly="true" width="80" align="center"/>
<EF:EFColumn ename="equipmentType" cname="设备状态" enable="false" readonly="true" width="100" align="center"/>
<EF:EFColumn ename="equipmentCode" cname="设备编码" enable="false" readonly="true" width="100" align="center"/>
<EF:EFColumn ename="dataContent" cname="数据内容" enable="false" readonly="true" width="100" align="center"/>
<EF:EFColumn ename="prio" cname="数据内容" enable="false" readonly="true" width="100" align="center"/>
<EF:EFColumn ename="rowno" cname="行号" enable="false" readonly="true" width="100" align="center"/>
<EF:EFColumn ename="gotoRowNone" cname="不存在跳转行" enable="false" readonly="true" width="100" align="center"/>
<EF:EFColumn ename="fileName" cname="文件名" enable="false" readonly="true" width="100" align="center"/>
<EF:EFColumn ename="createdTime" cname="创建时间" enable="false" readonly="true" width="120" align="center"
parseFormats="['yyyyMMddHHmmss']" editType="datetime" dateFormat="yyyy-MM-dd HH:mm:ss"/>
</EF:EFGrid>
......
......@@ -10,7 +10,6 @@
<EF:EFRegion id="inqu" title="查询条件">
<div class="row">
<EF:EFInput cname="操作人" ename="inqu_status-0-createdName" colWidth="3"/>
<EF:EFInput cname="程序号" ename="inqu_status-0-programNo" colWidth="3"/>
</div>
</EF:EFRegion>
......@@ -18,10 +17,9 @@
<EF:EFGrid blockId="result" autoDraw="override" isFloat="true" checkMode="row">
<EF:EFColumn ename="id" cname="主键id" hidden="true"/>
<EF:EFColumn ename="createdName" cname="操作人" enable="false" readonly="true" width="150" align="center"/>
<EF:EFColumn ename="programNo" cname="程序号" enable="false" readonly="true" width="80" align="center"/>
<EF:EFColumn ename="equipmentType" cname="设备状态" enable="false" readonly="true" width="100" align="center"/>
<EF:EFColumn ename="equipmentCode" cname="设备编码" enable="false" readonly="true" width="100" align="center"/>
<EF:EFColumn ename="dataContent" cname="数据内容" enable="false" readonly="true" width="100" align="center"/>
<EF:EFColumn ename="logValue" cname="数据内容" enable="false" readonly="true" width="100" align="center"/>
<EF:EFColumn ename="createdTime" cname="创建时间" enable="false" readonly="true" width="120" align="center"
parseFormats="['yyyyMMddHHmmss']" editType="datetime" dateFormat="yyyy-MM-dd HH:mm:ss"/>
</EF:EFGrid>
......
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