Search in sources :

Example 1 with PanoramicIntoTheFactoryRecords

use of com.monitor.model.intothefactoryrecords.PanoramicIntoTheFactoryRecords in project new-cloud by xie-summer.

the class PanoramicIntoTheFactoryRecordsServiceImpl method listByDate.

@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED, rollbackFor = Exception.class)
public List<PanoramicIntoTheFactoryRecords> listByDate(String date) {
    Condition condition = new Condition(PanoramicIntoTheFactoryRecords.class, false);
    condition.createCriteria().andCondition(" delete_flag=1  and status=1 and date_format(snapshot_time,'%Y%m%d') = date_format('" + date + "','%Y%m%d')");
    condition.setOrderByClause(" snapshot_time desc ");
    List<PanoramicIntoTheFactoryRecords> factoryRecords = intoTheFactoryRecordsMapper.selectByCondition(condition);
    return factoryRecords;
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) PanoramicIntoTheFactoryRecords(com.monitor.model.intothefactoryrecords.PanoramicIntoTheFactoryRecords) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with PanoramicIntoTheFactoryRecords

use of com.monitor.model.intothefactoryrecords.PanoramicIntoTheFactoryRecords 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);
    }
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) PanoramicIntoTheFactoryRecords(com.monitor.model.intothefactoryrecords.PanoramicIntoTheFactoryRecords) PanoramicExceptionRecord(com.monitor.model.exceptionrecord.PanoramicExceptionRecord) ServiceException(com.cloud.core.ServiceException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with PanoramicIntoTheFactoryRecords

use of com.monitor.model.intothefactoryrecords.PanoramicIntoTheFactoryRecords in project new-cloud by xie-summer.

the class PanoramicIntoTheFactoryRecordsServiceImpl method findByDate.

@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED, rollbackFor = Exception.class)
public PanoramicIntoTheFactoryRecords findByDate(String date) {
    Condition condition = new Condition(PanoramicIntoTheFactoryRecords.class, false);
    condition.createCriteria().andCondition(" delete_flag=1 and status=1  and date_format(snapshot_time,'%Y%m%d') = date_format('" + date + "','%Y%m%d') and err_msg is not null");
    condition.setOrderByClause(" snapshot_time desc ");
    List<PanoramicIntoTheFactoryRecords> factoryRecords = intoTheFactoryRecordsMapper.selectByCondition(condition);
    return (null == factoryRecords || factoryRecords.size() == 0) ? null : factoryRecords.get(0);
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) PanoramicIntoTheFactoryRecords(com.monitor.model.intothefactoryrecords.PanoramicIntoTheFactoryRecords) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

PanoramicIntoTheFactoryRecords (com.monitor.model.intothefactoryrecords.PanoramicIntoTheFactoryRecords)3 Transactional (org.springframework.transaction.annotation.Transactional)3 Condition (tk.mybatis.mapper.entity.Condition)3 ServiceException (com.cloud.core.ServiceException)1 PanoramicExceptionRecord (com.monitor.model.exceptionrecord.PanoramicExceptionRecord)1