use of com.monitor.model.exceptionrecord.PanoramicExceptionRecord in project new-cloud by xie-summer.
the class PanoramicIntoTheFactoryRecordsServiceImpl method regularlyRefreshTask.
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void regularlyRefreshTask() {
Condition condition = new Condition(PanoramicIntoTheFactoryRecords.class, false);
condition.createCriteria().andCondition(" err_msg is null and delete_flag=1 and status=1 and date_format(snapshot_time,'%Y%m%d') = date_format('" + DateUtil.currentTimeStr() + "','%Y%m%d') ");
condition.setOrderByClause(" snapshot_time desc ");
List<PanoramicIntoTheFactoryRecords> records = intoTheFactoryRecordsMapper.selectByCondition(condition);
if (null == records || records.size() == 0) {
return;
}
List<PanoramicExceptionRecord> exceptionRecords = Lists.newArrayList();
records.forEach(e -> {
try {
if (null == e.getNetWeight() || e.getNetWeight() == 0) {
e.setErrMsg("数据异常,记录数据没有净重值");
}
if (e.getTare() / e.getNetWeight() >= 0.006) {
e.setErrMsg("超重");
}
if (e.getTare() / e.getNetWeight() <= -0.006) {
e.setErrMsg("缺重");
}
if (StringUtils.isNotBlank(e.getErrMsg())) {
PanoramicExceptionRecord exceptionRecord = new PanoramicExceptionRecord();
exceptionRecord.setStatus(0);
exceptionRecord.setOperator("auto_task");
exceptionRecord.setId(null);
exceptionRecord.setDtime(null);
exceptionRecord.setCtime(DateUtil.getCurFullTimestamp());
exceptionRecord.setUtime(exceptionRecord.getCtime());
exceptionRecord.setAlarmTime(exceptionRecord.getCtime());
exceptionRecord.setAlarmContent(e.getErrMsg());
exceptionRecord.setAssociatedPerson(null);
exceptionRecord.setDeleteFlag(1);
exceptionRecord.setAlarmItem(ExceptionRecordCategoryConstant.IN_OR_OUT_EXCEPTION_RECORD);
exceptionRecords.add(exceptionRecord);
}
} catch (Exception e1) {
DB_LOGGER.error("数据异常,记录数据没有净重值");
}
if (Optional.ofNullable(e.getErrMsg()).isPresent()) {
e.setMemo("<-- auto task {\"更新异常信息\"}:" + e.getErrMsg() + DateUtil.currentTimeStr() + "-->");
e.setUtime(DateUtil.getCurFullTimestamp());
}
intoTheFactoryRecordsMapper.updateByPrimaryKeySelective(e);
});
if (null != exceptionRecords && exceptionRecords.size() > 0) {
exceptionRecordService.save(exceptionRecords);
}
}
use of com.monitor.model.exceptionrecord.PanoramicExceptionRecord in project new-cloud by xie-summer.
the class PanoramicInventoryEntryServiceImpl method manualEntryExceptionRecordTask.
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void manualEntryExceptionRecordTask(String date) {
Condition condition = new Condition(PanoramicInventoryEntry.class, false);
condition.createCriteria().andCondition(" f_id=2 and delete_flag=1 and utime > '" + DateUtil.parseTimestamp(date, "yyyy-MM-dd") + "' and utime < '" + DateUtil.parseTimestamp(DateUtil.getSpecifiedDayBefor(date, -1), "yyyy-MM-dd") + "'");
Integer count = inventoryEntryMapper.selectCountByCondition(condition);
if (6 == count) {
return;
}
PanoramicExceptionRecord record = new PanoramicExceptionRecord();
record.setAlarmItem(ExceptionRecordCategoryConstant.MANUAL_ENTRY_EXCEPTION_RECORD);
record.setDeleteFlag(1);
record.setAlarmContent("人工录入模块有数据漏录入");
record.setAssociatedPerson("当前管理员");
record.setAlarmTime(DateUtil.parseDate(date));
record.setCtime(DateUtil.getCurFullTimestamp());
record.setDtime(null);
record.setId(null);
record.setOperator("auto_task");
record.setRelatedPersonLog("定时任务自动扫描-人工录入异常遗漏数据");
record.setStatus(0);
record.setUtime(DateUtil.getCurFullTimestamp());
exceptionRecordService.save(record);
}
use of com.monitor.model.exceptionrecord.PanoramicExceptionRecord in project new-cloud by xie-summer.
the class PanoramicExceptionRecordController method delete.
@DeleteMapping("/{id}")
@ApiOperation(value = "异常信修改接口", notes = "更新异常信息状态,即删除异常信息")
public ResultCode<Void> delete(@PathVariable Integer id) {
PanoramicExceptionRecord record = exceptionRecordService.findById(id);
record.setDeleteFlag(0);
record.setUtime(DateUtil.getCurFullTimestamp());
record.setDtime(record.getUtime());
exceptionRecordService.update(record);
return ResultCode.SUCCESS;
}
Aggregations