Search in sources :

Example 61 with Condition

use of tk.mybatis.mapper.entity.Condition in project new-cloud by xie-summer.

the class PanoramicDailyInventorySummaryServiceImpl method listByDateAndCode.

@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED, rollbackFor = Exception.class)
public List<PanoramicDailyInventorySummary> listByDateAndCode(String date) {
    Condition condition = new Condition(PanoramicDailyInventorySummary.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") + "'");
    condition.setOrderByClause(" utime desc ");
    List<PanoramicDailyInventorySummary> recordList = dailyInventorySummaryMapper.selectByCondition(condition);
    return recordList;
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) PanoramicDailyInventorySummary(com.monitor.model.dailyinventorysummary.PanoramicDailyInventorySummary) Transactional(org.springframework.transaction.annotation.Transactional)

Example 62 with Condition

use of tk.mybatis.mapper.entity.Condition in project new-cloud by xie-summer.

the class PanoramicExceptionRecordServiceImpl method getPanoramicExceptionRecords.

private List<PanoramicExceptionRecord> getPanoramicExceptionRecords(String category, String startDate, String endDate) {
    Condition condition = new Condition(PanoramicExceptionRecord.class, false);
    StringBuilder sb = new StringBuilder("delete_flag=1 and alarm_time >='" + startDate + "' and alarm_time <='" + DateUtil.getSpecifiedDayBefor(endDate, -1));
    if (StringUtils.isNotBlank(category)) {
        sb.append("'  and alarm_item = '" + category + "'");
    }
    condition.createCriteria().andCondition(sb.toString());
    condition.setOrderByClause(" status desc ");
    condition.setOrderByClause(" alarm_time desc ");
    return exceptionRecordMapper.selectByCondition(condition);
}
Also used : Condition(tk.mybatis.mapper.entity.Condition)

Example 63 with Condition

use of tk.mybatis.mapper.entity.Condition 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 64 with Condition

use of tk.mybatis.mapper.entity.Condition 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)

Example 65 with Condition

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

Aggregations

Condition (tk.mybatis.mapper.entity.Condition)69 Criteria (tk.mybatis.mapper.entity.Example.Criteria)25 Transactional (org.springframework.transaction.annotation.Transactional)21 PostMapping (org.springframework.web.bind.annotation.PostMapping)21 MachineOrder (com.eservice.api.model.machine_order.MachineOrder)15 Machine (com.eservice.api.model.machine.Machine)13 TaskRecord (com.eservice.api.model.task_record.TaskRecord)10 Date (java.util.Date)10 PageInfo (com.github.pagehelper.PageInfo)9 ArrayList (java.util.ArrayList)9 ProcessRecord (com.eservice.api.model.process_record.ProcessRecord)8 ServerToClientMsg (com.eservice.api.service.mqtt.ServerToClientMsg)7 Contract (com.eservice.api.model.contract.Contract)6 ContractSign (com.eservice.api.model.contract_sign.ContractSign)6 Task (com.eservice.api.model.task.Task)6 PanoramicRealTimeConsumptionGather (com.monitor.model.realtimeconsumptiongather.PanoramicRealTimeConsumptionGather)6 OrderSign (com.eservice.api.model.order_sign.OrderSign)5 User (com.cas.sim.tis.entity.User)4 User (com.eservice.api.model.user.User)4 AbnormalRecord (com.eservice.api.model.abnormal_record.AbnormalRecord)3