Commit 1cec0d24 by TEEMO\xzh64

修改设备日志记录,添加定时任务,清除30天之前的日志

parent 803e53fd
......@@ -30,13 +30,27 @@ public class LogInformationController extends ServiceBase {
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() == 1) {
if (cutterbarStatusList.get(0).getStatus() > 2) {
hpsb001.setId(StringUtils.uuid());
hpsb001.setErrorCode(cutterbarWarning.getErrorCode());
hpsb001.setPrio(cutterbarWarning.getPrio());
......@@ -45,7 +59,7 @@ public class LogInformationController extends ServiceBase {
hpsb001.setGotoRowNone(cutterbarWarning.getGotoRowNone());
hpsb001.setFileName(cutterbarWarning.getFileName());
hpsb001.setEquipmentCode(hpsb00A.getEquipmentCode());
hpsb001.setEquipmentType(cutterbarStatusList.get(0).getStatus().toString());
hpsb001.setEquipmentType(value);
DaoUtils.insert("HPSB001.insert", hpsb001);
return "设备异常日志记录成功";
}
......@@ -57,9 +71,12 @@ public class LogInformationController extends ServiceBase {
hpsb002.setGotoRowNone(cutterbarWarning.getGotoRowNone());
hpsb002.setFileName(cutterbarWarning.getFileName());
hpsb002.setEquipmentCode(hpsb00A.getEquipmentCode());
hpsb002.setEquipmentType(cutterbarStatusList.get(0).getStatus().toString());
hpsb002.setEquipmentType(value);
DaoUtils.insert("HPSB002.insert", hpsb002);
return "设备日志记录成功";
}
}
......@@ -50,7 +50,7 @@ public class ServiceHPSB001 extends ServiceBase {
@OperationLogAnnotation(operModul = "设备异常日志",operType = "新增",operDesc = "新增")
@Override
public EiInfo insert(EiInfo inInfo) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
try {
HPSB001 hpsb001 = new HPSB001();
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
......@@ -82,7 +82,7 @@ public class ServiceHPSB001 extends ServiceBase {
*/
@OperationLogAnnotation(operModul = "设备异常日志",operType = "修改",operDesc = "修改")
public EiInfo update(EiInfo inInfo) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
try {
HPSB001 hpsb001 = new HPSB001();
EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
......@@ -132,4 +132,12 @@ public class ServiceHPSB001 extends ServiceBase {
return eiInfo;
}
/**
* 定时删除操作.
*/
@OperationLogAnnotation(operModul = "设备异常日志", operType = "删除", operDesc = "删除30天之前的历史数据")
public EiInfo deleteHistory(EiInfo inInfo) {
return super.delete(inInfo,"HPSB001.deleteByCreatedTime");
}
}
......@@ -132,4 +132,12 @@ public class ServiceHPSB002 extends ServiceBase {
return eiInfo;
}
/**
* 定时删除操作.
*/
@OperationLogAnnotation(operModul = "设备日志", operType = "删除", operDesc = "删除30天之前的历史数据")
public EiInfo deleteHistory(EiInfo inInfo) {
return super.delete(inInfo,"HPSB002.deleteByCreatedTime");
}
}
......@@ -141,6 +141,11 @@
ID = #id#
</delete>
<delete id="deleteByCreatedTime">
DELETE FROM hpjx.t_hpsb001 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_hpsb001
SET
......
......@@ -141,6 +141,11 @@
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
......
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